netgis_map_client_update #452
@ -48,9 +48,7 @@ class SimpleGeomForm(BaseForm):
|
||||
raise AttributeError
|
||||
|
||||
geojson = self.instance.geometry.as_feature_collection(srid=DEFAULT_SRID_RLP)
|
||||
|
||||
geojson = self._set_editable_status(geojson)
|
||||
|
||||
geojson = self._set_properties(geojson, self.instance.identifier)
|
||||
geom = json.dumps(geojson)
|
||||
except AttributeError:
|
||||
# If no geometry exists for this form, we simply set the value to None and zoom to the maximum level
|
||||
@ -227,7 +225,7 @@ class SimpleGeomForm(BaseForm):
|
||||
geom = gdal.OGRGeometry(g_wkt)
|
||||
return geom
|
||||
|
||||
def _set_editable_status(self, geojson: dict):
|
||||
def _set_properties(self, geojson: dict, title: str):
|
||||
""" Toggles the editable property of the geojson for proper handling in map client
|
||||
|
||||
Args:
|
||||
@ -238,7 +236,7 @@ class SimpleGeomForm(BaseForm):
|
||||
"""
|
||||
features = geojson.get("features", [])
|
||||
for feature in features:
|
||||
feature["properties"] = {
|
||||
"editable": not self.read_only
|
||||
}
|
||||
feature["properties"]["editable"] = not self.read_only
|
||||
if title:
|
||||
feature["properties"]["title"] = title
|
||||
return geojson
|
||||
|
@ -342,6 +342,7 @@ class Geometry(BaseResource):
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": json.loads(p.json),
|
||||
"properties": {},
|
||||
}
|
||||
for p in polygons
|
||||
]
|
||||
|
@ -10,11 +10,10 @@ from json import JSONDecodeError
|
||||
|
||||
import requests
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import JsonResponse, HttpRequest
|
||||
from django.http import JsonResponse, HttpRequest, HttpResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.http import urlencode
|
||||
from django.views import View
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from requests.auth import HTTPDigestAuth
|
||||
|
||||
@ -60,24 +59,7 @@ class ClientProxyParcelSearch(BaseClientProxyView):
|
||||
def get(self, request: HttpRequest):
|
||||
url = request.META.get("QUERY_STRING")
|
||||
content, response_code = self.perform_url_call(url)
|
||||
try:
|
||||
body = json.loads(content)
|
||||
except JSONDecodeError as e:
|
||||
body = {
|
||||
"totalResultsCount": -1,
|
||||
"geonames": [
|
||||
{
|
||||
"title": _("The external service is currently unavailable.<br>Please try again in a few moments...")
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if response_code != 200:
|
||||
return JsonResponse({
|
||||
"status_code": response_code,
|
||||
"content": body,
|
||||
})
|
||||
return JsonResponse(body)
|
||||
return HttpResponse(content)
|
||||
|
||||
|
||||
class ClientProxyParcelWFS(BaseClientProxyView):
|
||||
|
@ -34,8 +34,9 @@
|
||||
"center_lonlat": [ 7.0, 51.0 ],
|
||||
"zoom": 12,
|
||||
"min_zoom": 5,
|
||||
"max_zoom": 19,
|
||||
"scalebar": true
|
||||
"max_zoom": 24,
|
||||
"scalebar": true,
|
||||
"move_tolerance": 5
|
||||
},
|
||||
"folders":
|
||||
[
|
||||
@ -225,9 +226,10 @@
|
||||
"snapping":
|
||||
{
|
||||
"show": true,
|
||||
"active": true,
|
||||
"active": false,
|
||||
"tolerance": 10
|
||||
},
|
||||
"bounds_message": "Ausserhalb des erlaubten Bereichs!",
|
||||
"show_bounds": true
|
||||
},
|
||||
"output":
|
||||
|
2
templates/map/client/dist/netgis.min.css
vendored
2
templates/map/client/dist/netgis.min.css
vendored
File diff suppressed because one or more lines are too long
143
templates/map/client/dist/netgis.min.js
vendored
143
templates/map/client/dist/netgis.min.js
vendored
@ -10,29 +10,30 @@ netgis.Attribution=function(a){this.config=a;this.layers=this.client=null;this.i
|
||||
netgis.Attribution.prototype.attachTo=function(a){a.appendChild(this.container);a.addEventListener(netgis.Events.MAP_LAYER_TOGGLE,this.onMapLayerToggle.bind(this));a.addEventListener(netgis.Events.MAP_EDIT_LAYER_CHANGE,this.onEditLayerChange.bind(this))};netgis.Attribution.prototype.update=function(){var a="© "+this.items.join(", ");this.appendix&&(a+=", "+this.appendix);this.container.innerHTML=a};
|
||||
netgis.Attribution.prototype.add=function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]===a)return;this.items.push(a);this.update()};netgis.Attribution.prototype.remove=function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]===a){this.items.splice(b,1);break}this.update()};netgis.Attribution.prototype.onMapLayerToggle=function(a){a=a.detail;for(var b=this.config.layers,c=null,d=0;d<b.length;d++){var e=b[d];e.id===a.id&&(c=e.attribution)}c&&(a.on?this.add(c):this.remove(c))};
|
||||
netgis.Attribution.prototype.onContextUpdate=function(a){this.layers=[];for(var b=0;b<a.layers.length;b++){var c=a.layers[b];c.attribution&&0<c.attribution.length&&(this.layers[c.id]=c.attribution)}for(b=0;b<a.layers.length;b++)if(c=a.layers[b],c.active)this.onLayerShow({id:c.id})};netgis.Attribution.prototype.onLayerShow=function(a){if(a=this.layers[a.id]){for(var b=0;b<this.items.length;b++)if(this.items[b]===a)return;this.items.push(a);this.update()}};
|
||||
netgis.Attribution.prototype.onLayerHide=function(a){if(a=this.layers[a.id]){for(var b=0;b<this.items.length;b++)if(this.items[b]===a){this.items.splice(b,1);break}this.update()}};netgis.Attribution.prototype.onEditLayerChange=function(a){a=a.detail.geojson.area;for(var b=0;b<this.items.length;b++)if(-1<this.items[b].search("Zeichnungsfl\u00e4che: ")){this.items.splice(b,1);break}this.appendix=a&&0<a?"<b>Zeichnungsfl\u00e4che: "+netgis.util.formatArea(a,!0)+"</b>":null;this.update()};netgis=netgis||{};netgis.Client=function(a,b){this.container=this.initContainer(a);this.config=b;netgis.util.isString(b)?(this.showLoader(!0),netgis.util.request(b,this.onConfigResponse.bind(this))):this.init(this.container,b)};
|
||||
netgis.Client.prototype.init=function(a,b){this.config=b;this.logEvents=!1;this.initParams(b);this.initConfig(b);this.initElements(a);this.initModules(b);this.initEvents();this.initOutput(b);a=new netgis.ContextMenu;a.attachTo(this.container);this.modules.contextmenu=a;this.popup=new netgis.Popup;this.popup.attachTo(this.container)};netgis.Client.prototype.initContainer=function(a){netgis.util.isString(a)&&(a=document.getElementById(a));a.classList.add("netgis-client","netgis-font");return a};
|
||||
netgis.Attribution.prototype.onLayerHide=function(a){if(a=this.layers[a.id]){for(var b=0;b<this.items.length;b++)if(this.items[b]===a){this.items.splice(b,1);break}this.update()}};netgis.Attribution.prototype.onEditLayerChange=function(a){a=a.detail.geojson.area;for(var b=0;b<this.items.length;b++)if(-1<this.items[b].search("Zeichnungsfl\u00e4che: ")){this.items.splice(b,1);break}this.appendix=a&&0<a?"<b>Zeichnungsfl\u00e4che: "+netgis.util.formatArea(a,!0)+"</b>":null;this.update()};netgis=netgis||{};netgis.Client=function(a,b){this.container=this.initContainer(a);this.logEvents=!1;netgis.util.isString(b)?(this.showLoader(!0),netgis.util.request(b,this.onConfigResponse.bind(this))):this.init(this.container,b)};
|
||||
netgis.Client.prototype.init=function(a,b){this.config=b;this.initParams(b);this.initConfig(b);this.initElements(a);this.initModules(b);this.initEvents();this.initOutput(b);a=new netgis.ContextMenu;a.attachTo(this.container);this.modules.contextmenu=a;this.popup=new netgis.Popup;this.popup.attachTo(this.container)};netgis.Client.prototype.initContainer=function(a){netgis.util.isString(a)&&(a=document.getElementById(a));a.classList.add("netgis-client","netgis-font");return a};
|
||||
netgis.Client.prototype.initParams=function(a){var b=window.location.search.substr(1);b=b.split("&");this.params={};for(var c=0;c<b.length;c++){var d=b[c].split("="),e=d[0].toLowerCase();d=d[1];e&&""!==e&&(this.params[e]=d)}for(e in this.params)switch(d=this.params[e],e){case "wmc_id":a.wmc&&(a.wmc.id=d)}};netgis.Client.prototype.initConfig=function(a){a.wmc&&a.wmc.url&&this.requestContextWMC(a.wmc.url,a.wmc.id);a.ows&&a.ows.url&&this.requestContextOWS(a.ows.url)};
|
||||
netgis.Client.prototype.initElements=function(a){if(a.hasAttribute("data-lon")&&a.hasAttribute("data-lat")){var b=Number.parseFloat(a.getAttribute("data-lon")),c=Number.parseFloat(a.getAttribute("data-lat"));this.config.map.center_lonlat=[b,c]}a.hasAttribute("data-zoom")&&(b=Number.parseFloat(a.getAttribute("data-zoom")),this.config.map.zoom=b);a.hasAttribute("data-bounds")&&(b=a.getAttribute("data-bounds"),this.config.tools.bounds=b);a.hasAttribute("data-editable")&&(b="true"===a.getAttribute("data-editable"),
|
||||
this.config.tools||(this.config.tools={}),this.config.tools.editable=b);this.container=a};netgis.Client.prototype.initOutput=function(a){if(a.output&&a.output.id){if((a=document.getElementById(a.output.id))&&a.value&&0<a.value.length){var b=JSON.parse(a.value);netgis.util.invoke(this.container,netgis.Events.MAP_EDIT_LAYER_LOADED,{geojson:b})}this.output=a}this.output||(this.output=document.createElement("input"),this.output.setAttribute("type","hidden"),this.output.className="netgis-storage",this.container.appendChild(this.output))};
|
||||
netgis.Client.prototype.initElements=function(a){if(a.hasAttribute("data-lon")){var b=Number.parseFloat(a.getAttribute("data-lon"));this.config.map.center_lonlat||(this.config.map.center_lonlat=[]);this.config.map.center_lonlat[0]=b}a.hasAttribute("data-lat")&&(b=Number.parseFloat(a.getAttribute("data-lat")),this.config.map.center_lonlat||(this.config.map.center_lonlat=[]),this.config.map.center_lonlat[1]=b);a.hasAttribute("data-zoom")&&(b=Number.parseFloat(a.getAttribute("data-zoom")),this.config.map.zoom=
|
||||
b);a.hasAttribute("data-bounds")&&(b=a.getAttribute("data-bounds"),this.config.tools.bounds=b);a.hasAttribute("data-editable")&&(a="true"===a.getAttribute("data-editable"),this.config.tools||(this.config.tools={}),this.config.tools.editable=a)};
|
||||
netgis.Client.prototype.initOutput=function(a){if(a.output&&a.output.id){if((a=document.getElementById(a.output.id))&&a.value&&0<a.value.length){var b=JSON.parse(a.value);netgis.util.invoke(this.container,netgis.Events.MAP_EDIT_LAYER_LOADED,{geojson:b})}this.output=a}this.output||(this.output=document.createElement("input"),this.output.setAttribute("type","hidden"),this.output.className="netgis-storage",this.container.appendChild(this.output))};
|
||||
netgis.Client.prototype.initModules=function(a){this.modules={};if(a=a.modules)a.map&&this.addModule("map",netgis.Map),a.controls&&this.addModule("controls",netgis.Controls),a.attribution&&this.addModule("attribution",netgis.Attribution),a.info&&this.addModule("info",netgis.Info),a.menu&&this.addModule("menu",netgis.Menu),a.layertree&&this.addModule("layertree",netgis.LayerTree),a.searchplace&&this.addModule("searchplace",netgis.SearchPlace),a.searchparcel&&this.addModule("searchparcel",netgis.SearchParcel),
|
||||
a.toolbox&&this.addModule("toolbox",netgis.Toolbox),a["import"]&&this.addModule("import",netgis.Import),a["export"]&&this.addModule("export",netgis.Export),a.timeslider&&this.addModule("timeslider",netgis.TimeSlider)};
|
||||
netgis.Client.prototype.initEvents=function(){this.container.addEventListener(void 0,function(a){console.error("undefined event invoked",a)});for(var a in netgis.Events)this.container.addEventListener(netgis.Events[a],this.handleEvent.bind(this));this.container.addEventListener(netgis.Events.MAP_EDIT_LAYER_CHANGE,this.onMapEditLayerChange.bind(this))};
|
||||
netgis.Client.prototype.showLoader=function(a){this.loader||(this.loader=document.createElement("div"),this.loader.className="netgis-loader netgis-color-e netgis-text-a",this.loader.innerHTML="<i class='fas fa-cog'></i>",this.container.appendChild(this.loader));!1===a?this.loader.classList.add("netgis-hide"):this.loader.classList.remove("netgis-hide")};netgis.Client.prototype.handleEvent=function(a){var b=a.type;a=a.detail;!0===this.logEvents&&console.info("EVENT:",b,a)};
|
||||
netgis.Client.prototype.addModule=function(a,b){b=new b(this.config);b.attachTo&&b.attachTo(this.container);return this.modules[a]=b};netgis.Client.prototype.isMobile=function(){return netgis.util.isMobile(this.container)};netgis.Client.prototype.onConfigResponse=function(a){a=JSON.parse(a);this.init(this.container,a);this.showLoader(!1)};
|
||||
netgis.Client.prototype.requestContextWMC=function(a,b){if(-1<a.indexOf("{id}"))if(b)a=netgis.util.replace(a,"{id}",b);else{console.warn("No WMC id set in config for url",a);return}(new netgis.WMC).requestContext(a,this.onContextResponseWMC.bind(this))};
|
||||
netgis.Client.prototype.onContextResponseWMC=function(a){for(var b=0;b<a.config.layers.length;b++)this.config.layers.push(a.config.layers[b]);a.config.map.bbox&&(this.config.map.bbox=a.config.map.bbox);netgis.util.invoke(this.container,netgis.Events.CONTEXT_RESPONSE,{context:a})};netgis.Client.prototype.requestContextOWS=function(a){console.info("Request OWS:",a);netgis.util.request(a,this.onContextResponseOWS.bind(this))};
|
||||
netgis.Client.prototype.onContextResponseWMC=function(a){console.info("WMC Response:",a);for(var b=0;b<a.config.layers.length;b++)this.config.layers.push(a.config.layers[b]);a.config.map.bbox&&(this.config.map.bbox=a.config.map.bbox);netgis.util.invoke(this.container,netgis.Events.CLIENT_CONTEXT_RESPONSE,{context:a})};netgis.Client.prototype.requestContextOWS=function(a){console.info("Request OWS:",a);netgis.util.request(a,this.onContextResponseOWS.bind(this))};
|
||||
netgis.Client.prototype.onContextResponseOWS=function(a){a=JSON.parse(a);console.info("OWS Response:",a);a=netgis.OWS.read(a,this);console.info("OWS Config:",a)};netgis.Client.prototype.onIconbarIconClick=function(a){switch(a.detail.id){case "home":a=this.config.layers;for(var b=0;b<a.length;b++){var c=a[b],d=c.id;!0===c.active?(this.modules.map.addLayer(d,c),this.modules.layertree.tree.setItemChecked(d,!0)):(this.modules.map.removeLayer(d),this.modules.layertree.tree.setItemChecked(d,!1))}}};
|
||||
netgis.Client.prototype.onIconbarItemClick=function(a){a=a.detail;for(var b=this.config.layers,c=0;c<b.length;c++){var d=b[c],e=d.id;"background"!==d.folder&&(e===a.id?(this.modules.map.addLayer(e,d),this.modules.layertree.tree.setItemChecked(e,!0)):(this.modules.map.removeLayer(e),this.modules.layertree.tree.setItemChecked(e,!1)))}};
|
||||
netgis.Client.prototype.onSwitcherButtonClick=function(a){a=a.detail;for(var b=this.config.switcher.buttons,c=this.config.layers,d=0;d<b.length;d++){var e=b[d].id;if(e===a.id)for(var f=0;f<c.length;f++){var g=c[f];g.id===e&&(this.modules.map.addLayer(e,g),this.modules.layertree.tree.setItemChecked(e,!0))}else this.modules.map.removeLayer(e),this.modules.layertree.tree.setItemChecked(e,!1)}0===this.modules.switcher.getIndex(a.id)&&this.modules.switcher.shift(1,0)};
|
||||
netgis.Client.prototype.onGeolocationToggle=function(a){this.modules.map.setGeolocMarkerVisible(a.detail.on)};netgis.Client.prototype.onGeolocationChange=function(a){a=a.detail;this.modules.map.zoomLonLat(a.lon,a.lat,this.config.geolocation.zoom);this.modules.map.setGeolocMarkerLonLat(a.lon,a.lat)};netgis.Client.prototype.onMapEditLayerChange=function(a){a=JSON.stringify(a.detail.geojson);this.output.value=a};
|
||||
netgis.Client.handleCommand=function(a,b){switch(b){case netgis.Commands.LAYERTREE:netgis.util.invoke(a,netgis.Events.LAYERTREE_TOGGLE,null);break;case netgis.Commands.SEARCHPLACE:netgis.util.invoke(a,netgis.Events.SEARCHPLACE_TOGGLE,null);break;case netgis.Commands.SEARCHPARCEL:netgis.util.invoke(a,netgis.Events.SEARCHPARCEL_TOGGLE,null);break;case netgis.Commands.TOOLBOX:netgis.util.invoke(a,netgis.Events.TOOLBOX_TOGGLE,null);break;case netgis.Commands.VIEW_PREV:netgis.util.invoke(a,netgis.Events.MAP_VIEW_PREV,
|
||||
null);break;case netgis.Commands.VIEW_NEXT:netgis.util.invoke(a,netgis.Events.MAP_VIEW_NEXT,null);break;case netgis.Commands.VIEW:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW});break;case netgis.Commands.ZOOM_BOX:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.ZOOM_BOX});break;case netgis.Commands.MEASURE_LINE:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MEASURE_LINE});break;case netgis.Commands.MEASURE_AREA:netgis.util.invoke(a,
|
||||
netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MEASURE_AREA});break;case netgis.Commands.MEASURE_CLEAR:netgis.util.invoke(a,netgis.Events.MEASURE_CLEAR,null);break;case netgis.Commands.DRAW_POINTS:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_POINTS});break;case netgis.Commands.DRAW_LINES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_LINES});break;case netgis.Commands.DRAW_POLYGONS:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_POLYGONS});
|
||||
break;case netgis.Commands.MODIFY_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MODIFY_FEATURES});break;case netgis.Commands.DELETE_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DELETE_FEATURES});break;case netgis.Commands.BUFFER_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES});break;case netgis.Commands.CUT_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES});
|
||||
break;case netgis.Commands.IMPORT_LAYER:netgis.util.invoke(a,netgis.Events.IMPORT_LAYER_SHOW,null);break;case netgis.Commands.EXPORT:netgis.util.invoke(a,netgis.Events.EXPORT_SHOW,null);break;default:console.warn("unhandled command id",b)}};netgis=netgis||{};
|
||||
netgis.Commands=Object.freeze({LAYERTREE:"layertree",SEARCHPLACE:"searchplace",SEARCHPARCEL:"searchparcel",TOOLBOX:"toolbox",VIEW_PREV:"view_prev",VIEW_NEXT:"view_next",VIEW:"view",ZOOM_BOX:"zoom_box",MEASURE_LINE:"measure_line",MEASURE_AREA:"measure_area",MEASURE_CLEAR:"measure_clear",DRAW_POINTS:"draw_points",DRAW_LINES:"draw_lines",DRAW_POLYGONS:"draw_polygons",MODIFY_FEATURES:"modify_features",DELETE_FEATURES:"delete_features",BUFFER_FEATURES:"buffer_features",CUT_FEATURES:"cut_features",SNAP_TOGGLE:"snap_toggle",
|
||||
IMPORT_LAYER:"import_layer",EXPORT:"export"});netgis=netgis||{};netgis.ContextMenu=function(){this.initElements()};netgis.ContextMenu.prototype.initElements=function(){this.container=document.createElement("div");this.container.className="netgis-contextmenu netgis-shadow-large netgis-color-e netgis-hide"};
|
||||
null);break;case netgis.Commands.VIEW_NEXT:netgis.util.invoke(a,netgis.Events.MAP_VIEW_NEXT,null);break;case netgis.Commands.VIEW:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW});break;case netgis.Commands.ZOOM_BOX:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.ZOOM_BOX});break;case netgis.Commands.ZOOM_SCALE:b=Number.parseInt(a.innerText.split(":")[1]);netgis.util.invoke(a,netgis.Events.MAP_ZOOM_SCALE,{scale:b,anim:!0});break;case netgis.Commands.MEASURE_LINE:netgis.util.invoke(a,
|
||||
netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MEASURE_LINE});break;case netgis.Commands.MEASURE_AREA:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MEASURE_AREA});break;case netgis.Commands.MEASURE_CLEAR:netgis.util.invoke(a,netgis.Events.MEASURE_CLEAR,null);break;case netgis.Commands.DRAW_POINTS:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_POINTS});break;case netgis.Commands.DRAW_LINES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_LINES});
|
||||
break;case netgis.Commands.DRAW_POLYGONS:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DRAW_POLYGONS});break;case netgis.Commands.MODIFY_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.MODIFY_FEATURES});break;case netgis.Commands.DELETE_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.DELETE_FEATURES});break;case netgis.Commands.BUFFER_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES_DYNAMIC});
|
||||
break;case netgis.Commands.CUT_FEATURES:netgis.util.invoke(a,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES});break;case netgis.Commands.IMPORT_LAYER:netgis.util.invoke(a,netgis.Events.IMPORT_LAYER_SHOW,null);break;case netgis.Commands.EXPORT:netgis.util.invoke(a,netgis.Events.EXPORT_SHOW,null);break;default:console.warn("unhandled command id",b)}};netgis=netgis||{};
|
||||
netgis.Commands=Object.freeze({LAYERTREE:"layertree",SEARCHPLACE:"searchplace",SEARCHPARCEL:"searchparcel",TOOLBOX:"toolbox",VIEW_PREV:"view_prev",VIEW_NEXT:"view_next",VIEW:"view",ZOOM_BOX:"zoom_box",ZOOM_SCALE:"zoom_scale",MEASURE_LINE:"measure_line",MEASURE_AREA:"measure_area",MEASURE_CLEAR:"measure_clear",DRAW_POINTS:"draw_points",DRAW_LINES:"draw_lines",DRAW_POLYGONS:"draw_polygons",MODIFY_FEATURES:"modify_features",DELETE_FEATURES:"delete_features",BUFFER_FEATURES:"buffer_features",CUT_FEATURES:"cut_features",
|
||||
SNAP_TOGGLE:"snap_toggle",IMPORT_LAYER:"import_layer",EXPORT:"export"});netgis=netgis||{};netgis.ContextMenu=function(){this.initElements()};netgis.ContextMenu.prototype.initElements=function(){this.container=document.createElement("div");this.container.className="netgis-contextmenu netgis-shadow-large netgis-color-e netgis-hide"};
|
||||
netgis.ContextMenu.prototype.attachTo=function(a){a.appendChild(this.container);a.addEventListener(netgis.Events.CONTEXTMENU_SHOW,this.onContextMenuShow.bind(this));a.addEventListener("click",this.onParentClick.bind(this));a.addEventListener("pointerup",this.onParentClick.bind(this));a.addEventListener("scroll",this.onParentScroll.bind(this),!0);a.addEventListener("keydown",this.onParentKeyDown.bind(this))};netgis.ContextMenu.prototype.clear=function(){this.container.innerHTML=""};
|
||||
netgis.ContextMenu.prototype.addButton=function(a,b){var c=document.createElement("button");c.className="netgis-button netgis-clip-text netgis-hover-d";c.innerHTML=b;c.setAttribute("type","button");c.setAttribute("data-id",a);c.addEventListener("click",this.onButtonClick.bind(this));this.container.appendChild(c);return c};
|
||||
netgis.ContextMenu.prototype.addCheckbox=function(a,b,c){var d=document.createElement("label");d.className="netgis-noselect netgis-hover-d";var e=document.createElement("input");e.setAttribute("type","checkbox");e.setAttribute("title",b);e.setAttribute("data-id",a);e.checked=c;e.addEventListener("change",this.onCheckboxChange.bind(this));d.appendChild(e);a=document.createElement("span");a.className="netgis-clip-text";a.innerHTML=b;d.appendChild(a);this.container.appendChild(d);return e};
|
||||
@ -124,8 +125,9 @@ netgis.Info.prototype.onMapClick=function(a){a=a.detail;if(a.mode===netgis.Modes
|
||||
"{height}",a.view.height),e=netgis.util.replace(e,"{x}",a.pixel[0]),e=netgis.util.replace(e,"{y}",a.pixel[1]),e=netgis.util.replace(e,"{lon}",a.lon),e=netgis.util.replace(e,"{lat}",a.lat),console.info("WMS REQUEST 2:",e),netgis.util.request(e,this.onLayerResponseWMS.bind(this),{title:d.title}),b+=1)}0<b?(this.popup.showLoader(),this.popup.show()):this.popup.hide()}};
|
||||
netgis.Info.prototype.onLayerResponseWMS=function(a,b){this.popup.hideLoader();this.popup.addContent(["<details><summary class='netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-d'>",b.title,"</summary><div>",a,"</div></details>"].join(""))};netgis=netgis||{};netgis.LayerID=Object.freeze({EDITABLE:"editable-layer",NON_EDITABLE:"non-editable-layer"});netgis=netgis||{};netgis.LayerTree=function(a){this.config=a;this.importFolder=null;this.initElements();this.initConfig(a);this.initFolders()};netgis.LayerTree.prototype.initElements=function(){this.panel=new netgis.Panel("Layers");this.tree=new netgis.Tree;this.tree.attachTo(this.panel.content);this.tree.container.addEventListener(netgis.Events.TREE_ITEM_CHANGE,this.onTreeItemChange.bind(this));this.tree.container.addEventListener(netgis.Events.TREE_ITEM_SLIDER_CHANGE,this.onTreeItemSliderChange.bind(this))};
|
||||
netgis.LayerTree.prototype.initFolders=function(){this.editFolder=this.tree.addFolder(null,"edit-folder","Zeichnung",!0);this.tree.addCheckbox(this.editFolder,netgis.LayerID.EDITABLE,"Editierbar");this.tree.setItemChecked(netgis.LayerID.EDITABLE,!0);this.tree.addCheckbox(this.editFolder,netgis.LayerID.NON_EDITABLE,"Nicht-Editierbar");this.tree.setItemChecked(netgis.LayerID.NON_EDITABLE,!0);this.editFolder.classList.add("netgis-hide")};
|
||||
netgis.LayerTree.prototype.initConfig=function(a,b){a.layertree&&a.layertree.title&&this.panel.setTitle(a.layertree.title);for(var c=a.folders,d={},e=0;e<c.length;e++){var f=c[e],g=this.tree.addFolder(null,f.id,f.title,b,!1);d[f.id]=g;!0===f.open&&this.tree.setFolderOpen(f.id,!0)}b=a.layers;for(e=0;e<b.length;e++){g=b[e];f=d[g.folder]?d[g.folder]:null;var h=g.id?g.id:e.toString(),k=!1;if(f)for(var l=0;l<c.length;l++){var m=c[l];m.id===g.folder&&(k=m.radio)}g=!0===k?this.tree.addRadioButton(f,h,g.title,
|
||||
g.active,this.createDefaultDetails(g)):this.tree.addCheckbox(f,h,g.title,g.active,!1,this.createDefaultDetails(g));g.addEventListener("contextmenu",this.onTreeItemMenu.bind(this))}this.tree.updateFolderChecks();c=a.layertree.buttons;for(e=0;e<c.length;e++)d=c[e],this.tree.addButton(null,d.id,d.title,this.onTreeButtonClick.bind(this));a.layertree&&!0===a.layertree.open&&this.panel.show()};
|
||||
netgis.LayerTree.prototype.initConfig=function(a,b){a.layertree&&a.layertree.title&&this.panel.setTitle(a.layertree.title);for(var c=a.folders,d={},e=0;e<c.length;e++){var f=c[e],g=this.tree.addFolder(null,f.id,f.title,b,!1);d[f.id]=g;!0===f.open&&this.tree.setFolderOpen(f.id,!0)}for(e=0;e<c.length;e++)f=c[e],g=f.id,f=f.parent,-1===f&&(f=null),""===f&&(f=null),f&&this.tree.setFolderParent(d[g],d[f]);b=a.layers;for(e=0;e<b.length;e++){var h=b[e];f=d[h.folder]?d[h.folder]:null;g=h.id?h.id:e.toString();
|
||||
var k=!1;if(f)for(var l=0;l<c.length;l++){var m=c[l];m.id===h.folder&&(k=m.radio)}g=!0===k?this.tree.addRadioButton(f,g,h.title,h.active,this.createDefaultDetails(h)):this.tree.addCheckbox(f,g,h.title,h.active,!1,this.createDefaultDetails(h));g.addEventListener("contextmenu",this.onTreeItemMenu.bind(this))}this.tree.updateFolderChecks();if(a.layertree&&a.layertree.buttons)for(c=a.layertree.buttons,e=0;e<c.length;e++)d=c[e],this.tree.addButton(null,d.id,d.title,this.onTreeButtonClick.bind(this));a.layertree&&
|
||||
!0===a.layertree.open&&this.panel.show()};
|
||||
netgis.LayerTree.prototype.attachTo=function(a){a.appendChild(this.panel.container);a.addEventListener(netgis.Events.CLIENT_CONTEXT_RESPONSE,this.onClientContextResponse.bind(this));a.addEventListener(netgis.Events.LAYERTREE_TOGGLE,this.onLayerTreeToggle.bind(this));a.addEventListener(netgis.Events.TOOLBOX_TOGGLE,this.onToolboxToggle.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_TOGGLE,this.onSearchParcelToggle.bind(this));a.addEventListener(netgis.Events.MAP_LAYER_TOGGLE,this.onMapLayerToggle.bind(this));
|
||||
a.addEventListener(netgis.Events.IMPORT_LAYER_ACCEPT,this.onImportLayerAccept.bind(this));a.addEventListener(netgis.Events.IMPORT_GEOPORTAL_SUBMIT,this.onImportGeoportalSubmit.bind(this));a.addEventListener(netgis.Events.CONTEXTMENU_SLIDER_CHANGE,this.onContextMenuSliderChange.bind(this));a.addEventListener(netgis.Events.MAP_EDIT_LAYER_LOADED,this.onMapEditLayerChange.bind(this));a.addEventListener(netgis.Events.MAP_EDIT_LAYER_CHANGE,this.onMapEditLayerChange.bind(this))};
|
||||
netgis.LayerTree.prototype.createDefaultDetails=function(a){return[{title:"Transparenz:",type:"slider",val:a.transparency?Math.round(100*a.transparency):0}]};netgis.LayerTree.prototype.onTreeItemChange=function(a){var b=a.detail;netgis.util.invoke(a.target,netgis.Events.MAP_LAYER_TOGGLE,{id:b.id,on:b.checked})};netgis.LayerTree.prototype.onClientContextResponse=function(a){this.initConfig(a.detail.context.config,!0)};netgis.LayerTree.prototype.onLayerTreeToggle=function(a){this.panel.toggle()};
|
||||
@ -133,7 +135,7 @@ netgis.LayerTree.prototype.onToolboxToggle=function(a){this.panel.hide()};netgis
|
||||
netgis.LayerTree.prototype.onImportLayerAccept=function(a){a=a.detail;this.importFolder||(this.importFolder=this.tree.addFolder(null,"_import","Import",!0,!1));this.tree.addCheckbox(this.importFolder,a.id,a.title,!0,!0,this.createDefaultDetails(a)).addEventListener("contextmenu",this.onTreeItemMenu.bind(this));this.tree.updateFolderChecks()};
|
||||
netgis.LayerTree.prototype.onImportGeoportalSubmit=function(a){a=a.detail;var b=a.folder.id,c=this.tree.getFolder(b);c||(c=this.tree.addFolder(null,b,a.folder.title,!0,!1));var d=a.layer.id;b={id:d,folder:b,title:a.layer.title,active:!0,type:netgis.LayerTypes.WMS,url:a.layer.url,name:a.layer.name,order:1E4,transparency:0};this.config.layers.push(b);this.tree.addCheckbox(c,d,a.layer.title,!1,!1,this.createDefaultDetails(b));this.tree.setItemChecked(d,!0,!1)};
|
||||
netgis.LayerTree.prototype.onTreeItemMenu=function(a){a.preventDefault();return!1};netgis.LayerTree.prototype.onContextMenuSliderChange=function(a){var b=a.detail;a=.01*b.val;var c=null;0===b.id.indexOf("layer_trans_")&&(c=b.id.split("layer_trans_")[1]);b=this.config.layers;for(var d=0;d<b.length;d++){var e=b[d];if(e.id===c){e.transparency=a;break}}netgis.util.invoke(this.tree.container,netgis.Events.MAP_LAYER_TRANSPARENCY,{id:c,transparency:a})};
|
||||
netgis.LayerTree.prototype.onTreeItemSliderChange=function(a){var b=a.detail;a=b.id;b=.01*b.val;for(var c=this.config.layers,d=0;d<c.length;d++){var e=c[d];if(e.id===a){e.transparency=b;break}}netgis.util.invoke(this.tree.container,netgis.Events.MAP_LAYER_TRANSPARENCY,{id:a,transparency:b})};netgis.LayerTree.prototype.onMapEditLayerChange=function(a){this.editFolder.classList.remove("netgis-hide")};netgis=netgis||{};netgis.LayerTypes=Object.freeze({TMS:"TMS",WMTS:"WMTS",WMS:"WMS",WMST:"WMST",GEOJSON:"GEOJSON",VTILES:"VTILES",WFS:"WFS",GML:"GML",GEOPACKAGE:"GEOPACKAGE",SPATIALITE:"SPATIALITE",SHAPEFILE:"SHAPEFILE",WKT:"WKT",OSM:"OSM",XYZ:"XYZ"});netgis=netgis||{};netgis.Logic=function(a){this.client=a;this.config=a.config;this.container=a.container;this.modules=a.modules;this.initConfig(config);this.initEvents()};netgis.Logic.prototype.initConfig=function(a){a.wmc&&a.wmc.url&&(new netgis.WMC).requestContext(a.wmc.url,this.onContextLoaded.bind(this))};netgis.Logic.prototype.initEvents=function(){};
|
||||
netgis.LayerTree.prototype.onTreeItemSliderChange=function(a){var b=a.detail;a=b.id;b=.01*b.val;for(var c=this.config.layers,d=0;d<c.length;d++){var e=c[d];if(e.id===a){e.transparency=b;break}}netgis.util.invoke(this.tree.container,netgis.Events.MAP_LAYER_TRANSPARENCY,{id:a,transparency:b})};netgis.LayerTree.prototype.onMapEditLayerChange=function(a){this.editFolder.classList.remove("netgis-hide")};netgis=netgis||{};netgis.LayerTypes=Object.freeze({TMS:"TMS",WMTS:"WMTS",WMS:"WMS",WMST:"WMST",GEOJSON:"GEOJSON",VTILES:"VTILES",WFS:"WFS",GML:"GML",KML:"KML",GEOPACKAGE:"GEOPACKAGE",SPATIALITE:"SPATIALITE",SHAPEFILE:"SHAPEFILE",WKT:"WKT",OSM:"OSM",XYZ:"XYZ"});netgis=netgis||{};netgis.Logic=function(a){this.client=a;this.config=a.config;this.container=a.container;this.modules=a.modules;this.initConfig(config);this.initEvents()};netgis.Logic.prototype.initConfig=function(a){a.wmc&&a.wmc.url&&(new netgis.WMC).requestContext(a.wmc.url,this.onContextLoaded.bind(this))};netgis.Logic.prototype.initEvents=function(){};
|
||||
netgis.Logic.prototype.onMenuButtonClick=function(a){a=a.detail;switch(a.id){case "layertree":this.modules.layertree.panel.toggle();break;case "searchplace":this.modules.searchplace.search.toggle();break;default:console.error("unhandled menu button",a)}};netgis.Logic.prototype.onLayerItemChange=function(a){a=a.detail;if(a.checked)for(var b=this.config.layers,c=0;c<b.length;c++){var d=b[c];d.id===a.id&&this.modules.map.addLayer(a.id,d)}else this.modules.map.removeLayer(a.id)};
|
||||
netgis.Logic.prototype.onControlsButtonClick=function(a){switch(a.detail.id){case "zoom_in":this.modules.map.zoom(1);break;case "zoom_out":this.modules.map.zoom(-1);break;case "zoom_home":this.config.map.bbox?this.modules.map.zoomBBox(this.config.map.bbox,500):this.config.map.centerLonLat&&(a=this.config.map.centerLonLat,this.modules.map.zoomLonLat(a[0],a[1],this.config.map.zoom))}};
|
||||
netgis.Logic.prototype.onSearchPlaceChange=function(a){var b=this.config.searchplace.url;b=netgis.util.replace(b,"{query}",window.encodeURIComponent(a.detail.query));netgis.util.request(b,this.onSearchPlaceResponse.bind(this))};
|
||||
@ -141,10 +143,13 @@ netgis.Logic.prototype.onSearchPlaceResponse=function(a){a=JSON.parse(a).data;th
|
||||
netgis.Logic.prototype.onSearchPlaceSelect=function(a){a=JSON.parse(a.detail.data);this.modules.map.zoomLonLat(a.lon,a.lat,this.config.searchplace.zoom);if("street"===a.type){var b=this.config.searchplace.url_detail;b&&(b=netgis.util.replace(b,"{id}",a.id),netgis.util.request(b,this.onSearchPlaceDetailResponse.bind(this)))}};
|
||||
netgis.Logic.prototype.onSearchPlaceDetailResponse=function(a){a=JSON.parse(a);var b=a.hsnrarr;if(0!==b.length){this.modules.searchplace.search.clearResults();for(var c=0;c<b.length;c++){var d=b[c],e=a.strname+" "+d.hsnr;d={type:"address",lon:Number.parseFloat(d.wgs_x),lat:Number.parseFloat(d.wgs_y)};this.modules.searchplace.search.addResult(e,JSON.stringify(d))}}};netgis.Logic.prototype.onSearchPlaceClear=function(a){};
|
||||
netgis.Logic.prototype.onContextLoaded=function(a){console.info("Context Loaded:",a);for(var b=0;b<a.config.layers.length;b++)this.config.layers.push(a.config.layers[b]);a.config.map.bbox&&(this.config.map.bbox=a.config.map.bbox);this.modules.map&&this.modules.map.initConfig(a.config);this.modules.layertree&&this.modules.layertree.initConfig(a.config,!0)};netgis=netgis||{};
|
||||
netgis.Map=function(a){this.config=a;this.mode=null;this.interactions={};this.layers={};this.viewHistory=[];this.viewIndex=-1;this.viewFromHistory=!1;this.viewHistoryMax=20;this.hoverBounds=this.hoverFeature=null;this.selectedFeatures=[];this.sketchFeatures=[];this.snap=null;this.snapFeatures=new ol.Collection;this.drawError=this.selectMultiple=this.editEventsSilent=!1;this.initElements();this.initMap(a);this.initLayers();this.initOverlays();this.initInteractions();this.initConfig(a);this.setMode(netgis.Modes.VIEW)};
|
||||
netgis.Map.prototype.initElements=function(){this.container=document.createElement("div");this.container.setAttribute("tabindex",-1);this.container.className="netgis-map";this.container.addEventListener("pointerleave",this.onPointerLeave.bind(this));this.container.addEventListener("contextmenu",this.onRightClick.bind(this));this.container.addEventListener("keydown",this.onKeyDown.bind(this));this.container.addEventListener("keyup",this.onKeyUp.bind(this))};
|
||||
netgis.Map.prototype.initMap=function(a){var b=a.map;"undefined"!==typeof proj4&&(proj4.defs(a.projections),proj4.defs("urn:ogc:def:crs:OGC:1.3:CRS84",proj4.defs("EPSG:4326")),ol.proj.proj4.register(proj4));var c={projection:b.projection,center:b.center_lonlat?ol.proj.fromLonLat(b.center_lonlat,b.projection):b.center,minZoom:b.min_zoom,maxZoom:b.max_zoom,zoom:b.zoom};this.view=new ol.View(c);this.map=new ol.Map({target:this.container,view:this.view,pixelRatio:1,moveTolerance:5,controls:[]});b.scalebar&&
|
||||
(this.scalebar=new ol.control.ScaleLine({bar:!0}),this.map.addControl(this.scalebar));this.map.on("moveend",this.onMapMoveEnd.bind(this));this.map.on("pointermove",this.onPointerMove.bind(this));this.map.on("click",this.onPointerClick.bind(this));if(a.map.extent){var d=this;window.setTimeout(function(){d.map.updateSize();d.view.fit(a.map.extent)},10)}};
|
||||
netgis.Map=function(a){this.config=a;this.mode=null;this.interactions={};this.layers={};this.viewHistory=[];this.viewIndex=-1;this.viewFromHistory=!1;this.viewHistoryMax=20;this.paddingBuffer=40;this.hoverBounds=this.hoverFeature=null;this.selectedFeatures=[];this.sketchFeatures=[];this.snap=null;this.snapFeatures=new ol.Collection;this.drawError=this.selectMultiple=this.editEventsSilent=!1;this.initElements();this.initMap(a);this.initLayers();this.initOverlays();this.initInteractions();this.initConfig(a);
|
||||
this.setPadding(0,0,0,0);this.setMode(netgis.Modes.VIEW)};
|
||||
netgis.Map.prototype.initElements=function(){this.container=document.createElement("div");this.container.setAttribute("tabindex",-1);this.container.className="netgis-map";this.container.addEventListener("pointerleave",this.onPointerLeave.bind(this));this.container.addEventListener("click",this.onContainerClick.bind(this));this.container.addEventListener("contextmenu",this.onRightClick.bind(this));this.container.addEventListener("keydown",this.onKeyDown.bind(this));this.container.addEventListener("keyup",
|
||||
this.onKeyUp.bind(this))};
|
||||
netgis.Map.prototype.initMap=function(a){var b=a.map;"undefined"!==typeof proj4&&(proj4.defs(a.projections),proj4.defs("urn:ogc:def:crs:OGC:1.3:CRS84",proj4.defs("EPSG:4326")),ol.proj.proj4.register(proj4));var c={projection:b.projection,center:b.center_lonlat?ol.proj.fromLonLat(b.center_lonlat,b.projection):b.center,minZoom:b.min_zoom,maxZoom:b.max_zoom,zoom:b.zoom};this.view=new ol.View(c);this.map=new ol.Map({target:this.container,view:this.view,pixelRatio:1,moveTolerance:b.move_tolerance||0===
|
||||
b.move_tolerance?b.move_tolerance:7,controls:[]});if(b.scalebar&&(this.scalebar=new ol.control.ScaleLine({bar:!0}),this.map.addControl(this.scalebar),(b=b.scales)&&0<b.length))for(this.scalebarSelect=document.createElement("select"),this.scalebarSelect.addEventListener("change",this.onScalebarSelectChange.bind(this)),this.scalebar.element.appendChild(this.scalebarSelect),c=0;c<b.length;c++){var d=b[c],e=document.createElement("option");e.innerHTML="1:"+d;e.setAttribute("value",d);this.scalebarSelect.appendChild(e)}this.map.on("moveend",
|
||||
this.onMapMoveEnd.bind(this));this.map.on("pointermove",this.onPointerMove.bind(this));this.map.on("click",this.onPointerClick.bind(this));if(a.map.extent){var f=this;window.setTimeout(function(){f.map.updateSize();f.view.fit(a.map.extent)},10)}};
|
||||
netgis.Map.prototype.initLayers=function(){this.measureLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),zIndex:6E4,style:this.styleMeasure.bind(this)});this.map.addLayer(this.measureLayer);var a=this.config.tools;this.nonEditLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),zIndex:5E4,style:this.styleNonEdit.bind(this),updateWhileAnimating:a.interactive_render,updateWhileInteracting:a.interactive_render});this.map.addLayer(this.nonEditLayer);this.editLayer=
|
||||
new ol.layer.Vector({source:new ol.source.Vector({features:[]}),zIndex:5E4,style:this.styleEdit.bind(this),updateWhileAnimating:a.interactive_render,updateWhileInteracting:a.interactive_render});this.map.addLayer(this.editLayer);this.editLayer.getSource().on("addfeature",this.onEditLayerAdd.bind(this));this.editLayer.getSource().on("changefeature",this.onEditLayerChange.bind(this));this.editLayer.getSource().on("removefeature",this.onEditLayerRemove.bind(this));this.previewLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),
|
||||
zIndex:55E3,style:this.styleSketch.bind(this)});this.map.addLayer(this.previewLayer);this.boundsLayer=null;if(this.config.tools.bounds){a=(new ol.format.GeoJSON).readFeatures(this.config.tools.bounds);var b=null;this.config.tools.show_bounds&&this.config.styles.bounds&&(b=this.createStyle(this.config.styles.bounds));this.boundsLayer=new ol.layer.Vector({source:new ol.source.Vector({features:a}),style:b,zIndex:6E4});this.map.addLayer(this.boundsLayer)}};
|
||||
@ -164,23 +169,23 @@ a.addEventListener(netgis.Events.MAP_LAYER_TRANSPARENCY,this.onMapLayerTranspare
|
||||
a.addEventListener(netgis.Events.DRAW_BUFFER_CHANGE,this.onDrawBufferChange.bind(this));a.addEventListener(netgis.Events.BUFFER_CHANGE,this.onBufferChange.bind(this));a.addEventListener(netgis.Events.BUFFER_ACCEPT,this.onBufferAccept.bind(this));a.addEventListener(netgis.Events.IMPORT_LAYER_ACCEPT,this.onImportLayerAccept.bind(this));a.addEventListener(netgis.Events.IMPORT_LAYER_PREVIEW,this.onImportLayerPreview.bind(this));a.addEventListener(netgis.Events.IMPORT_GEOPORTAL_SUBMIT,this.onImportGeoportalSubmit.bind(this));
|
||||
a.addEventListener(netgis.Events.MAP_COPY_FEATURE_TO_EDIT,this.onCopyFeatureToEdit.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_ITEM_ENTER,this.onSearchParcelItemEnter.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_ITEM_LEAVE,this.onSearchParcelItemLeave.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_ITEM_CLICK,this.onSearchParcelItemClick.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_ITEM_IMPORT,this.onSearchParcelItemImport.bind(this));a.addEventListener(netgis.Events.EXPORT_BEGIN,
|
||||
this.onExportBegin.bind(this));a.addEventListener(netgis.Events.TIMESLIDER_SHOW,this.onTimeSliderShow.bind(this));a.addEventListener(netgis.Events.TIMESLIDER_HIDE,this.onTimeSliderHide.bind(this));a.addEventListener(netgis.Events.TIMESLIDER_SELECT,this.onTimeSliderSelect.bind(this))};
|
||||
netgis.Map.prototype.setMode=function(a){switch(this.mode){case netgis.Modes.MODIFY_FEATURES:this.editLayer.setStyle(this.styleEdit.bind(this));break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.previewLayer.getSource().clear();this.container.classList.remove("netgis-not-allowed");break;case netgis.Modes.DRAW_POLYGONS:this.container.classList.remove("netgis-not-allowed");break;case netgis.Modes.BUFFER_FEATURES_EDIT:this.clearSketchFeatures()}this.map.getInteractions().clear();this.mode&&
|
||||
this.container.classList.remove("netgis-mode-"+this.mode);var b=this.interactions[a];b||(console.warn("no interactions found for mode",a),b=this.interactions[netgis.Modes.VIEW]);for(var c=0;c<b.length;c++)this.map.addInteraction(b[c]);b=this.config.tools.editable;switch(a){case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:b&&(this.setSnapping(this.drawSnapOn),this.onDrawBufferToggle({detail:{on:this.drawBufferOn,radius:this.drawBufferRadius,segments:this.drawBufferSegments}}));break;case netgis.Modes.DRAW_POLYGONS:b&&
|
||||
this.setSnapping(this.drawSnapOn);break;case netgis.Modes.MODIFY_FEATURES:b&&this.editLayer.setStyle(this.styleModify.bind(this))}this.container.classList.add("netgis-mode-"+a);this.mode=a};
|
||||
netgis.Map.prototype.setMode=function(a){switch(this.mode){case netgis.Modes.MODIFY_FEATURES:this.editLayer.setStyle(this.styleEdit.bind(this));break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.previewLayer.getSource().clear();this.container.classList.remove("netgis-not-allowed");this.container.removeAttribute("title");break;case netgis.Modes.DRAW_POLYGONS:this.container.classList.remove("netgis-not-allowed");this.container.removeAttribute("title");break;case netgis.Modes.BUFFER_FEATURES:this.clearSketchFeatures();
|
||||
break;case netgis.Modes.BUFFER_FEATURES_EDIT:this.clearSketchFeatures(),this.selectedFeatures=[],this.redrawVectorLayers()}this.map.getInteractions().clear();this.mode&&this.container.classList.remove("netgis-mode-"+this.mode);var b=this.interactions[a];b||(console.warn("no interactions found for mode",a),b=this.interactions[netgis.Modes.VIEW]);for(var c=0;c<b.length;c++)this.map.addInteraction(b[c]);b=this.config.tools.editable;switch(a){case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:b&&
|
||||
(this.setSnapping(this.drawSnapOn),this.onDrawBufferToggle({detail:{on:this.drawBufferOn,radius:this.drawBufferRadius,segments:this.drawBufferSegments}}));break;case netgis.Modes.DRAW_POLYGONS:b&&this.setSnapping(this.drawSnapOn);break;case netgis.Modes.MODIFY_FEATURES:b&&(this.setSnapping(this.drawSnapOn),this.editLayer.setStyle(this.styleModify.bind(this)))}this.container.classList.add("netgis-mode-"+a);this.mode=a};
|
||||
netgis.Map.prototype.addLayer=function(a,b){var c=this.createLayer(b);c&&(c.set("id",a),this.map.addLayer(c),this.layers[a]=c,b.order&&c.setZIndex(b.order),b.transparency&&c.setOpacity(1-b.transparency),b.style&&c.setStyle(this.createStyle(b.style)),b.min_zoom&&c.setMinZoom(b.min_zoom-1E-4),b.max_zoom&&c.setMaxZoom(b.max_zoom),c instanceof ol.layer.Vector&&this.addSnapLayer(c),b.type===netgis.LayerTypes.WMST&&netgis.util.invoke(this.container,netgis.Events.TIMESLIDER_SHOW,{layer:a,title:b.title,url:b.url,
|
||||
name:b.name}));return c};
|
||||
netgis.Map.prototype.createLayer=function(a){switch(a.type){case netgis.LayerTypes.TMS:case netgis.LayerTypes.XYZ:var b=this.createLayerTMS(a.url,a.projection,a.extent,a.scales);break;case netgis.LayerTypes.OSM:b=this.createLayerTMS("https://{a-c}.tile.openstreetmap.de/{z}/{x}/{y}.png");break;case netgis.LayerTypes.WMTS:b=this.createLayerWMTS(a.url,a.name);break;case netgis.LayerTypes.WMS:b=this.createLayerWMS(a.url,a.name,a.format,a.tiled,a.username,a.password);break;case netgis.LayerTypes.WMST:b=this.createLayerWMST(a.url,
|
||||
a.name,a.format,a.tiled,a.username,a.password);break;case netgis.LayerTypes.GEOJSON:(b=a.data)&&netgis.util.isString(b)&&(b=JSON.parse(b));b=this.createLayerGeoJSON(b?b:a.url);break;case netgis.LayerTypes.WFS:b=this.createLayerWFS(a.url,a.name,this.view.getProjection().getCode(),a.format,a.username,a.password);break;case netgis.LayerTypes.VTILES:b=this.createLayerVectorTiles(a.url,a.extent,a.min_zoom,a.max_zoom);break;case netgis.LayerTypes.GML:b=this.createLayerGML(a.data);break;case netgis.LayerTypes.GEOPACKAGE:b=
|
||||
this.createLayerGeoPackage(a.data);break;case netgis.LayerTypes.SPATIALITE:b=this.createLayerSpatialite(a.data);break;case netgis.LayerTypes.SHAPEFILE:b=this.createLayerShapefile(a.data);break;case netgis.LayerTypes.WKT:b=this.createLayerWKT(a.data);break;default:console.error("unknown layer type",a.type)}return b};
|
||||
a.name,a.format,a.tiled,a.username,a.password);break;case netgis.LayerTypes.GEOJSON:(b=a.data)&&netgis.util.isString(b)&&(b=JSON.parse(b));b=this.createLayerGeoJSON(b?b:a.url);break;case netgis.LayerTypes.WFS:b=this.createLayerWFS(a.url,a.name,this.view.getProjection().getCode(),a.format,a.username,a.password);break;case netgis.LayerTypes.VTILES:b=this.createLayerVectorTiles(a.url,a.extent,a.min_zoom,a.max_zoom);break;case netgis.LayerTypes.GML:b=this.createLayerGML(a.data);break;case netgis.LayerTypes.KML:b=
|
||||
this.createLayerKML(a.url);break;case netgis.LayerTypes.GEOPACKAGE:b=this.createLayerGeoPackage(a.data);break;case netgis.LayerTypes.SPATIALITE:b=this.createLayerSpatialite(a.data);break;case netgis.LayerTypes.SHAPEFILE:b=this.createLayerShapefile(a.data);break;case netgis.LayerTypes.WKT:b=this.createLayerWKT(a.data);break;default:console.error("unknown layer type",a.type)}return b};
|
||||
netgis.Map.prototype.removeLayer=function(a){var b=this.layers[a];b instanceof ol.layer.Vector&&this.removeSnapLayer(b);for(var c=0;c<this.config.layers.length;c++)if(this.config.layers[c].id===a){this.config.layers[c].type===netgis.LayerTypes.WMST&&netgis.util.invoke(this.container,netgis.Events.TIMESLIDER_HIDE,null);break}this.map.removeLayer(b);delete this.layers[a]};netgis.Map.prototype.setLayerOrder=function(a,b){this.layers[a].setZIndex(b)};
|
||||
netgis.Map.prototype.createStyle=function(a){var b=a.radius?a.radius:3,c=a.width?a.width:1,d=a.fill?a.fill:"gray",e=a.stroke?a.stroke:"black";return function(a){return new ol.style.Style({image:new ol.style.Circle({radius:b-c,fill:new ol.style.Fill({color:d})}),fill:new ol.style.Fill({color:d}),stroke:new ol.style.Stroke({color:e,width:c})})}};
|
||||
netgis.Map.prototype.styleMeasure=function(a){var b=a.getGeometry(),c=this.config.measure,d=new ol.style.Style({fill:new ol.style.Fill({color:c.area_fill}),stroke:new ol.style.Stroke({color:c.line_color,width:c.line_width,lineDash:c.line_dash})});b instanceof ol.geom.Polygon?(b=b.getArea(),d.setText(new ol.style.Text({text:[netgis.util.formatArea(b,!0),"4mm sans-serif"],font:"Arial",fill:new ol.style.Fill({color:c.text_color}),backgroundFill:new ol.style.Fill({color:c.text_back}),padding:[2,4,2,4],
|
||||
overflow:!0}))):b instanceof ol.geom.LineString&&(this.mode===netgis.Modes.MEASURE_LINE||this.mode===netgis.Modes.VIEW)&&(b=b.getLength(),d.setText(new ol.style.Text({text:[netgis.util.formatDistance(b),"4mm sans-serif"],font:"Arial",fill:new ol.style.Fill({color:c.text_color}),backgroundFill:new ol.style.Fill({color:c.text_back}),padding:[2,4,2,4],overflow:!0})));return c.point_radius&&0<c.point_radius?(b=this.getGeometryPoints(a),a=new ol.style.Style({image:new ol.style.Circle({radius:1.25*c.point_radius,
|
||||
fill:new ol.style.Fill({color:c.point_stroke})}),geometry:b}),c=new ol.style.Style({image:new ol.style.Circle({radius:c.point_radius,fill:new ol.style.Fill({color:c.point_fill})}),geometry:b}),[d,a,c]):d};
|
||||
netgis.Map.prototype.styleEdit=function(a){var b=this.config.styles.draw,c=this.config.styles.select,d=a.getGeometry(),e=this.hoverFeature===a;-1<this.selectedFeatures.indexOf(a)&&(e=!0);var f=e?c.fill:b.fill;a=e?c.stroke:b.stroke;c=new ol.style.Style({image:new ol.style.Circle({radius:e?c.radius:b.radius,fill:new ol.style.Fill({color:a})}),fill:new ol.style.Fill({color:f}),stroke:new ol.style.Stroke({color:a,width:b.width})});e&&c.setZIndex(1);if(d instanceof ol.geom.Polygon||d instanceof ol.geom.MultiPolygon){e=
|
||||
d.getArea();if(!e||0>=e)return c;!0===b.viewport_labels&&(b=this.view.calculateExtent(this.map.getSize()),f=ol.geom.Polygon.fromExtent(b),b=new jsts.io.OL3Parser,d=b.read(d),f=b.read(f),d=d.intersection(f),d=b.write(d),c.setGeometry(d));c.setText(new ol.style.Text({text:[netgis.util.formatArea(e,!0),"4mm sans-serif"],font:"Arial",fill:new ol.style.Fill({color:a}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]}))}return c};
|
||||
netgis.Map.prototype.styleNonEdit=function(a){var b=this.config.styles.non_edit,c=this.config.styles.select,d=a.getGeometry(),e=this.hoverFeature===a;-1<this.selectedFeatures.indexOf(a)&&(e=!0);var f=e?c.fill:b.fill;a=e?c.stroke:b.stroke;c=new ol.style.Style({image:new ol.style.Circle({radius:e?c.radius:b.radius,fill:new ol.style.Fill({color:a})}),fill:new ol.style.Fill({color:f}),stroke:new ol.style.Stroke({color:a,width:b.width})});e&&c.setZIndex(1);if(d instanceof ol.geom.Polygon){e=d.getArea();
|
||||
if(!e||0>=e)return c;!0===b.viewport_labels&&(b=this.map.getView().calculateExtent(this.map.getSize()),f=ol.geom.Polygon.fromExtent(b),b=new jsts.io.OL3Parser,d=b.read(d),f=b.read(f),d=d.intersection(f),d=b.write(d),c.setGeometry(d));c.setText(new ol.style.Text({text:[netgis.util.formatArea(e,!0),"4mm sans-serif"],font:"Arial",fill:new ol.style.Fill({color:a}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]}))}return c};
|
||||
netgis.Map.prototype.styleEdit=function(a){var b=this.config.styles.draw,c=this.config.styles.select,d=a.getGeometry(),e=this.hoverFeature===a;-1<this.selectedFeatures.indexOf(a)&&(e=!0);var f=e?c.fill:b.fill,g=e?c.stroke:b.stroke;c=new ol.style.Style({image:new ol.style.Circle({radius:e?c.radius:b.radius,fill:new ol.style.Fill({color:g})}),fill:new ol.style.Fill({color:f}),stroke:new ol.style.Stroke({color:g,width:b.width})});e&&c.setZIndex(1);if(d instanceof ol.geom.Polygon||d instanceof ol.geom.MultiPolygon){e=
|
||||
d.getArea();if(!e||0>=e)return c;!0===b.viewport_labels&&(b=this.view.calculateExtent(this.map.getSize()),f=ol.geom.Polygon.fromExtent(b),b=new jsts.io.OL3Parser,d=b.read(d),f=b.read(f),d=d.intersection(f),d=b.write(d),c.setGeometry(d));e=netgis.util.formatArea(e,!0);(a=a.getProperties().title)&&(e=a+"\n"+e);c.setText(new ol.style.Text({text:e,font:"4mm Arial, sans-serif",fill:new ol.style.Fill({color:g}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]}))}return c};
|
||||
netgis.Map.prototype.styleNonEdit=function(a){var b=this.config.styles.non_edit,c=this.config.styles.select,d=a.getGeometry(),e=this.hoverFeature===a;-1<this.selectedFeatures.indexOf(a)&&(e=!0);var f=e?c.fill:b.fill,g=e?c.stroke:b.stroke;c=new ol.style.Style({image:new ol.style.Circle({radius:e?c.radius:b.radius,fill:new ol.style.Fill({color:g})}),fill:new ol.style.Fill({color:f}),stroke:new ol.style.Stroke({color:g,width:b.width})});e&&c.setZIndex(1);if(d instanceof ol.geom.Polygon){e=d.getArea();
|
||||
if(!e||0>=e)return c;!0===b.viewport_labels&&(b=this.map.getView().calculateExtent(this.map.getSize()),f=ol.geom.Polygon.fromExtent(b),b=new jsts.io.OL3Parser,d=b.read(d),f=b.read(f),d=d.intersection(f),d=b.write(d),c.setGeometry(d));e=netgis.util.formatArea(e,!0);(a=a.getProperties().title)&&(e=a+"\n"+e);c.setText(new ol.style.Text({text:e,font:"4mm Arial, sans-serif",fill:new ol.style.Fill({color:g}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]}))}return c};
|
||||
netgis.Map.prototype.styleSketch=function(a){var b=this.config.styles[this.drawError?"error":"sketch"],c=a.getGeometry(),d=new ol.style.Style({image:new ol.style.Circle({radius:b.radius,fill:new ol.style.Fill({color:b.fill})}),fill:new ol.style.Fill({color:b.fill}),stroke:new ol.style.Stroke({color:b.stroke,width:b.width})});c instanceof ol.geom.Polygon&&(c=c.getArea(),d.setText(new ol.style.Text({text:[netgis.util.formatArea(c,!0),"4mm sans-serif"],font:"Arial",fill:new ol.style.Fill({color:b.stroke}),
|
||||
backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]})));a=new ol.style.Style({image:new ol.style.Circle({radius:b.radius,fill:new ol.style.Fill({color:b.stroke})}),geometry:this.getGeometryPoints(a)});return[d,a]};
|
||||
netgis.Map.prototype.styleModify=function(a){var b=this.config.styles.modify,c=new ol.style.Style({image:new ol.style.Circle({radius:b.radius,fill:new ol.style.Fill({color:b.stroke})}),fill:new ol.style.Fill({color:b.fill}),stroke:new ol.style.Stroke({color:b.stroke,width:b.width})}),d=new ol.style.Style({image:new ol.style.Circle({radius:b.radius,fill:new ol.style.Fill({color:b.stroke})}),geometry:this.getGeometryPoints(a)});a=a.getGeometry();a instanceof ol.geom.Polygon&&(a=a.getArea(),c.setText(new ol.style.Text({text:[netgis.util.formatArea(a,
|
||||
@ -210,53 +215,63 @@ e.push(new ol.Feature({geometry:m}))}}b.getSource().addFeatures(e)});return b};n
|
||||
netgis.Map.prototype.createLayerWKT=function(a){for(var b=new ol.format.WKT,c=[],d=0;d<a.length;d++){var e=a[d],f=b.readGeometry(e.geometry),g=e.properties;g.geometry=f;g.wkt=e.geometry;f=new ol.Feature(g);f.setId(e.id);c.push(f)}return new ol.layer.Vector({source:new ol.source.Vector({features:c})})};
|
||||
netgis.Map.prototype.createLayerWFS=function(a,b,c,d,e,f){"?"!==a[a.length-1]&&(a+="?");a+="service=WFS&version=1.1.0&request=GetFeature";c||(c=this.view.getProjection().getCode());d=d?netgis.util.replace(d," ","+"):"application/json";var g=new ol.source.Vector({format:new ol.format.GeoJSON,strategy:ol.loadingstrategy.bbox,loader:function(h,k,n,q,p){h=a+"&typename="+b+"&srsname="+c+"&bbox="+h.join(",")+","+c+"&outputFormat="+d;var l=new XMLHttpRequest;l.open("GET",h);e&&f&&l.setRequestHeader("Authorization",
|
||||
"Basic "+window.btoa(e+":"+f));l.onerror=function(){console.error("WFS request error");p()};l.onload=function(){if(200===l.status){g.clear();var a=g.getFormat().readFeatures(l.responseText);g.addFeatures(a);q(a)}else console.error("WFS request status",l.status),p()};l.send()}}),h=new ol.layer.Vector({source:g}),k=this;g.on("featuresloadstart",function(a){k.removeSnapLayer(h)});g.on("featuresloadend",function(a){window.setTimeout(function(){k.addSnapLayer(h)},10)});return h};
|
||||
netgis.Map.prototype.createLayerVectorTiles=function(a,b,c,d){return new ol.layer.VectorTile({extent:b,source:new ol.source.VectorTile({format:new ol.format.MVT,overlaps:!0,url:a,minZoom:c,maxZoom:d})})};netgis.Map.prototype.createBufferFeature=function(a,b,c){a=this.createBufferGeometry(a,b,c);return new ol.Feature({geometry:a})};
|
||||
netgis.Map.prototype.createBufferGeometry=function(a,b,c){var d=new jsts.io.OL3Parser;a=d.read(a).buffer(b,c);if(this.boundsLayer)for(b=this.boundsLayer.getSource().getFeatures(),c=0;c<b.length;c++){var e=d.read(b[c].getGeometry());a.intersects(e)&&(a=a.intersection(e))}return d.write(a)};
|
||||
netgis.Map.prototype.createLayerVectorTiles=function(a,b,c,d){return new ol.layer.VectorTile({extent:b,source:new ol.source.VectorTile({format:new ol.format.MVT,overlaps:!0,url:a,minZoom:c,maxZoom:d})})};
|
||||
netgis.Map.prototype.createLayerKML=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;netgis.util.request(a,function(a){a=(new ol.format.KML).readFeatures(a,{featureProjection:c.view.getProjection()});for(var d=0;d<a.length;d++){var f=a[d],g=f.getProperties(),h={fill:"rgba( 127, 127, 127, 0.5 )",stroke:"rgba( 127, 127, 127, 1.0 )",radius:5,width:3},k;for(k in g){var l=g[k];switch(k){case "fill":h.fill=l;break;case "fill-opacity":h["fill-opacity"]=l;break;case "stroke":h.stroke=
|
||||
l;break;case "stroke-opacity":h["stroke-opacity"]=l;break;case "stroke-width":h.width=l}}h["fill-opacity"]&&(g=netgis.util.hexToRGB(h.fill),g="rgba("+g.join(",")+","+h["fill-opacity"]+")",h.fill=g);h["stroke-opacity"]&&(g=netgis.util.hexToRGB(h.stroke),g="rgba("+g.join(",")+","+h["stroke-opacity"]+")",h.stroke=g);h=new ol.style.Style({image:new ol.style.Circle({radius:h.radius,fill:new ol.style.Fill({color:h.stroke})}),fill:new ol.style.Fill({color:h.fill}),stroke:new ol.style.Stroke({color:h.stroke,
|
||||
width:h.width})});f.setStyle(h)}b.getSource().addFeatures(a)});return b};netgis.Map.prototype.createBufferFeature=function(a,b,c){a=this.createBufferGeometry(a,b,c);return new ol.Feature({geometry:a})};netgis.Map.prototype.createBufferGeometry=function(a,b,c){var d=new jsts.io.OL3Parser;a=d.read(a).buffer(b,c);if(this.boundsLayer)for(b=this.boundsLayer.getSource().getFeatures(),c=0;c<b.length;c++){var e=d.read(b[c].getGeometry());a.intersects(e)&&(a=a.intersection(e))}return d.write(a)};
|
||||
netgis.Map.prototype.splitMultiPolygons=function(a){a=a.getSource();for(var b=a.getFeatures(),c=[],d=[],e=0;e<b.length;e++){var f=b[e],g=f.getGeometry();if(g instanceof ol.geom.MultiPolygon){g=g.getPolygons();for(var h=0;h<g.length;h++){var k=new ol.Feature({geometry:g[h]});d.push(k)}c.push(f)}}for(e=0;e<c.length;e++)a.removeFeature(c[e]);a.addFeatures(d)};
|
||||
netgis.Map.prototype.clearSketchFeatures=function(){for(var a=this.editLayer.getSource(),b=0;b<this.sketchFeatures.length;b++)a.removeFeature(this.sketchFeatures[b]);this.sketchFeatures=[]};
|
||||
netgis.Map.prototype.updateDrawBufferPreview=function(){if(!1!==this.config.tools.editable){var a=this.interactions[this.mode][0].getOverlay().getSource().getFeatures();if(!(1>a.length)){var b=this.previewLayer.getSource().getFeatures()[0];b&&(a=a[0].getGeometry(),a=this.createBufferGeometry(a,this.drawBufferRadius,this.drawBufferSegments),b.setGeometry(a))}}};
|
||||
netgis.Map.prototype.isPointInsideLayer=function(a,b){a=a.getSource().getFeatures();for(var c=0;c<a.length;c++)if(a[c].getGeometry().intersectsCoordinate(b))return!0;return!1};
|
||||
netgis.Map.prototype.isGeomInsideLayer=function(a,b){var c=b.getCoordinates();if(b instanceof ol.geom.LineString){if(2>c.length)return!0}else if(b instanceof ol.geom.Polygon&&(c=c[0],4>c.length||0>=b.getArea()))return!0;c=new jsts.io.OL3Parser;b=c.read(b);a=a.getSource().getFeatures();for(var d=0;d<a.length;d++){var e=a[d].getGeometry();if(c.read(e).contains(b))return!0}return!1};netgis.Map.prototype.getScaleFromResolution=function(a){return Math.round(2834.6472*a)};
|
||||
netgis.Map.prototype.isGeomInsideLayer=function(a,b){var c=b.getCoordinates();if(b instanceof ol.geom.LineString){if(2>c.length)return!1}else if(b instanceof ol.geom.Polygon&&(c=c[0],4>c.length||0>=b.getArea()))return!1;c=new jsts.io.OL3Parser;b=c.read(b);a=a.getSource().getFeatures();for(var d=0;d<a.length;d++){var e=a[d].getGeometry();if(c.read(e).contains(b))return!0}return!1};netgis.Map.prototype.getScaleFromResolution=function(a){return Math.round(2834.6472*a)};
|
||||
netgis.Map.prototype.getResolutionFromScale=function(a){var b=39.3701*ol.proj.Units.METERS_PER_UNIT[this.view.getProjection().getUnits()];return 1/(this.normalizeScale(a)*b*72)};netgis.Map.prototype.normalizeScale=function(a){return 1<a?1/a:a};
|
||||
netgis.Map.prototype.updateEditOutput=function(){var a=this.editLayer.getSource().getFeatures(),b=this.view.getProjection().getCode(),c=(new ol.format.GeoJSON).writeFeaturesObject(a,{dataProjection:b,featureProjection:b});c.crs={type:"name",properties:{name:"urn:ogc:def:crs:"+b.replace(":","::")}};for(var d=b=0;d<a.length;d++){var e=a[d].getGeometry();e instanceof ol.geom.Polygon&&(b+=e.getArea())}c.area=b;netgis.util.invoke(this.container,netgis.Events.MAP_EDIT_LAYER_CHANGE,{geojson:c})};
|
||||
netgis.Map.prototype.updateSnapFeatures=function(){this.snapFeatures.clear();var a=this;this.map.getLayers().forEach(function(b,c,d){c=b.get("id");c!==netgis.Client.Layers.PARCEL_DISTRICTS&&c!==netgis.Client.Layers.PARCEL_FIELDS&&c!==netgis.Client.Layers.PARCEL_FEATURES&&b instanceof ol.layer.Vector&&a.addSnapLayer(b)})};netgis.Map.prototype.zoom=function(a){this.view.animate({zoom:this.view.getZoom()+a,duration:200})};
|
||||
netgis.Map.prototype.zoomLevel=function(a){this.view.animate({zoom:a,center:this.view.getCenter(),duration:300})};netgis.Map.prototype.zoomLonLat=function(a,b,c){this.view.animate({zoom:c,center:ol.proj.fromLonLat([a,b],this.view.getProjection()),duration:500})};netgis.Map.prototype.zoomExtentLonLat=function(a,b,c,d){a=ol.proj.fromLonLat([a,b],this.view.getProjection());c=ol.proj.fromLonLat([c,d],this.view.getProjection());this.view.fit([a[0],a[1],c[0],c[1]])};
|
||||
netgis.Map.prototype.zoomExtent=function(a,b,c,d){this.view.fit([a,b,c,d])};netgis.Map.prototype.zoomBBox=function(a,b){this.view.fit(a,{duration:b})};netgis.Map.prototype.zoomScale=function(a){this.view.setResolution(this.getResolutionFromScale(a))};netgis.Map.prototype.zoomFeature=function(a,b){a=this.layers[a].getSource().getFeatureById(b);this.view.fit(a.getGeometry().getExtent(),{duration:500})};
|
||||
netgis.Map.prototype.zoomLevel=function(a){this.view.animate({zoom:a,center:this.view.getCenter(),duration:300})};netgis.Map.prototype.zoomCoords=function(a,b,c){this.view.animate({zoom:c,center:[a,b],duration:500})};netgis.Map.prototype.zoomLonLat=function(a,b,c){this.view.animate({zoom:c,center:ol.proj.fromLonLat([a,b],this.view.getProjection()),duration:500})};
|
||||
netgis.Map.prototype.zoomExtentLonLat=function(a,b,c,d){a=ol.proj.fromLonLat([a,b],this.view.getProjection());c=ol.proj.fromLonLat([c,d],this.view.getProjection());this.view.fit([a[0],a[1],c[0],c[1]])};netgis.Map.prototype.zoomExtent=function(a,b,c,d){this.view.fit([a,b,c,d])};netgis.Map.prototype.zoomBBox=function(a,b){this.view.fit(a,{duration:b})};netgis.Map.prototype.zoomScale=function(a,b){b?this.view.animate({resolution:this.getResolutionFromScale(a),duration:500}):this.view.setResolution(this.getResolutionFromScale(a))};
|
||||
netgis.Map.prototype.zoomFeature=function(a,b){a=this.layers[a].getSource().getFeatureById(b);this.view.fit(a.getGeometry().getExtent(),{duration:500})};netgis.Map.prototype.zoomFeatures=function(a){if(a&&!(1>a.length)){for(var b=a[0].getGeometry().getExtent(),c=1;c<a.length;c++)b=ol.extent.extend(b,a[c].getGeometry().getExtent());this.view.fit(b,{duration:0,padding:this.view.padding})}};
|
||||
netgis.Map.prototype.addViewHistory=function(a,b){if(0<this.viewHistory.length){var c=this.viewHistory[this.viewHistory.length-1],d=!0;10<Math.abs(a[0]-c.center[0])&&(d=!1);10<Math.abs(a[1]-c.center[1])&&(d=!1);.1<Math.abs(b-c.zoom)&&(d=!1);if(!0===d)return}this.viewHistory.push({center:a,zoom:b});this.viewHistory.length>this.viewHistoryMax&&this.viewHistory.shift();this.viewIndex=this.viewHistory.length-1};
|
||||
netgis.Map.prototype.gotoViewHistory=function(a){if(!(1>this.viewHistory.length)){var b=this.viewHistory.length-1;0>a&&(a=b);a>b&&(a=0);a!==this.viewIndex&&(b=this.viewHistory[a],this.viewIndex=a,this.viewFromHistory=!0,this.view.setCenter(b.center),this.view.setZoom(b.zoom))}};netgis.Map.prototype.setPadding=function(a,b,c,d){this.view.padding=[a+40,b+40,c+40,d+40]};
|
||||
netgis.Map.prototype.gotoViewHistory=function(a){if(!(1>this.viewHistory.length)){var b=this.viewHistory.length-1;0>a&&(a=b);a>b&&(a=0);a!==this.viewIndex&&(b=this.viewHistory[a],this.viewIndex=a,this.viewFromHistory=!0,this.view.setCenter(b.center),this.view.setZoom(b.zoom))}};netgis.Map.prototype.setPadding=function(a,b,c,d){var e=this.paddingBuffer;this.view.padding=[a+e,b+e,c+e,d+e]};
|
||||
netgis.Map.prototype.exportImage=function(a,b,c,d,e){var f=this,g=this.container,h=this.map,k=this.config["export"],l=new Image;l.onload=function(){var m=document.createElement("div");m.style.position="fixed";m.style.top="0px";m.style.left="0px";m.style.width=b+"px";m.style.height=c+"px";m.style.background="white";m.style.zIndex=-1;m.style.opacity=0;m.style.pointerEvents="none";g.appendChild(m);h.setTarget(m);h.once("rendercomplete",function(){var n=document.createElement("canvas");n.width=b;n.height=
|
||||
c;var q=n.getContext("2d");q.webkitImageSmoothingEnabled=!1;q.mozImageSmoothingEnabled=!1;q.imageSmoothingEnabled=!1;Array.prototype.forEach.call(document.querySelectorAll(".ol-layer canvas"),function(a){if(0<a.width){var b=a.parentNode.style.opacity;q.globalAlpha=""===b?1:Number(b);b=a.style.transform.match(/^matrix\(([^\(]*)\)$/)[1].split(",").map(Number);CanvasRenderingContext2D.prototype.setTransform.apply(q,b);q.drawImage(a,0,0)}});q.drawImage(l,0,0);q.fillStyle="#fff";q.fillRect(0,n.height-
|
||||
30,140,30);q.fillStyle="#000";q.font="4mm sans-serif";q.fillText(netgis.util.getTimeStamp(),10,n.height-10);var p=document.createElement("a");switch(a){case "pdf":e=e?e:0;var r=297-e-e,v=210-e-e,t=n.width/n.height;if(!d){var w=r;r=v;v=w}if(n.height>n.width){var u=v;w=u*t;w>r&&(w=r,u=w/t)}else w=r,u=w/t,u>v&&(u=v,w=u*t);t=new jsPDF(d?"l":"p");var x=e;x+=(r-w)/2;r=e;r+=(v-u)/2;t.addImage(n.toDataURL("image/png,1.0",1),"PNG",x,r,w,u);t.setFillColor(255,255,255);t.rect(x,r+u-11,80,11,"F");t.setFontSize(8);
|
||||
t.text("Datum: "+netgis.util.getTimeStamp(),x+2,r+u-2-4);t.text("Quelle: "+window.location.href,x+2,r+u-2);n=t.output("bloburl",{filename:k.default_filename+".pdf"});window.open(n,"_blank");break;case "jpeg":window.navigator.msSaveBlob?window.navigator.msSaveBlob(n.msToBlob(),k.default_filename+".jpg"):(p.setAttribute("download",k.default_filename+".jpg"),p.setAttribute("href",n.toDataURL("image/jpeg",1)),p.click());break;case "png":window.navigator.msSaveBlob?window.navigator.msSaveBlob(n.msToBlob(),
|
||||
k.default_filename+".png"):(p.setAttribute("download",k.default_filename+".png"),p.setAttribute("href",n.toDataURL("image/png",1)),p.click());break;case "gif":p.setAttribute("download",k.default_filename+".gif"),v=new GIF({workerScript:k.gif_worker,quality:1}),v.addFrame(n),v.on("finished",function(a){p.setAttribute("href",window.URL.createObjectURL(a));p.click()}),v.render()}h.setTarget(g);g.removeChild(m);netgis.util.invoke(f.container,netgis.Events.EXPORT_END,null)});h.renderSync()};l.src=k.logo};
|
||||
netgis.Map.prototype.exportFeatures=function(a){var b=this.editLayer.getSource().getFeatures();!0===a&&(a=this.nonEditLayer.getSource().getFeatures(),b=b.concat(a));b=(new ol.format.GeoJSON).writeFeaturesObject(b,{featureProjection:this.view.getProjection(),dataProjection:"EPSG:4326"});a=this.config["export"].default_filename+".geojson";b.name=a;netgis.util.downloadJSON(b,a);netgis.util.invoke(this.container,netgis.Events.EXPORT_END,null)};netgis.Map.prototype.onClientContextResponse=function(a){this.initConfig(a.detail.context.config)};
|
||||
netgis.Map.prototype.onEditLayerLoaded=function(a){a=a.detail.geojson;var b=new ol.format.GeoJSON;b.readProjection(a);a=b.readFeatures(a,{featureProjection:this.view.getProjection().getCode()});b=[];for(var c=0;c<a.length;c++){var d=a[c];!0===d.getProperties().editable&&b.push(d)}for(c=0;c<b.length;c++)a.splice(a.indexOf(b[c]),1);this.editEventsSilent=!0;this.editLayer.getSource().addFeatures(b);this.nonEditLayer.getSource().addFeatures(a);this.editEventsSilent=!1};
|
||||
netgis.Map.prototype.onClientSetMode=function(a){this.setMode(a.detail.mode)};netgis.Map.prototype.onPanelResize=function(a){this.setPadding(0,0,0,a.detail.width);this.redrawVectorLayers()};netgis.Map.prototype.onPanelToggle=function(a){a=!1;for(var b=0,c=this.container.parentNode.getElementsByClassName("netgis-panel"),d=0;d<c.length;d++)if(c[d].classList.contains("netgis-show")){a=!0;b=c[d].getBoundingClientRect().width;break}a?this.setPadding(0,0,0,b):this.setPadding(0,0,0,0);this.redrawVectorLayers()};
|
||||
netgis.Map.prototype.onMapZoom=function(a){this.zoom(a.detail.delta)};netgis.Map.prototype.onMapZoomHome=function(a){a=this.config;if(a.map.bbox)this.zoomBBox(a.map.bbox,500);else if(a.map.center_lonlat){var b=a.map.center_lonlat;this.zoomLonLat(b[0],b[1],a.map.zoom)}};netgis.Map.prototype.onMapZoomLonLat=function(a){a=a.detail;this.zoomLonLat(a.lon,a.lat,a.zoom)};netgis.Map.prototype.onMapZoomScale=function(a){this.zoomScale(a.detail.scale)};
|
||||
netgis.Map.prototype.onEditLayerLoaded=function(a){a=a.detail.geojson;var b=new ol.format.GeoJSON;b.readProjection(a);a=b.readFeatures(a,{featureProjection:this.view.getProjection().getCode()});var c=this,d=a.slice();window.setTimeout(function(){c.zoomFeatures(d)},10);b=[];for(var e=0;e<a.length;e++){var f=a[e];!0===f.getProperties().editable&&b.push(f)}for(e=0;e<b.length;e++)a.splice(a.indexOf(b[e]),1);this.editEventsSilent=!0;this.editLayer.getSource().addFeatures(b);this.nonEditLayer.getSource().addFeatures(a);
|
||||
this.editEventsSilent=!1};netgis.Map.prototype.onClientSetMode=function(a){this.setMode(a.detail.mode)};netgis.Map.prototype.onPanelResize=function(a){this.setPadding(0,0,0,a.detail.width);this.redrawVectorLayers()};
|
||||
netgis.Map.prototype.onPanelToggle=function(a){a=!1;for(var b=0,c=this.container.parentNode.getElementsByClassName("netgis-panel"),d=0;d<c.length;d++)if(c[d].classList.contains("netgis-show")){a=!0;b=c[d].getBoundingClientRect().width;break}a?this.setPadding(0,0,0,b):this.setPadding(0,0,0,0);this.redrawVectorLayers()};netgis.Map.prototype.onMapZoom=function(a){this.zoom(a.detail.delta)};
|
||||
netgis.Map.prototype.onMapZoomHome=function(a){a=this.config;if(a.map.bbox)this.zoomBBox(a.map.bbox,500);else if(a.map.center){var b=a.map.center;this.zoomCoords(b[0],b[1],a.map.zoom)}else a.map.center_lonlat&&(b=a.map.center_lonlat,this.zoomLonLat(b[0],b[1],a.map.zoom))};netgis.Map.prototype.onMapZoomLonLat=function(a){a=a.detail;this.zoomLonLat(a.lon,a.lat,a.zoom)};netgis.Map.prototype.onMapZoomScale=function(a){a=a.detail;this.zoomScale(a.scale,a.anim)};
|
||||
netgis.Map.prototype.onMapZoomLayer=function(a){a=a.detail;var b=this.layers[a.id];b?this.view.fit(b.getSource().getExtent(),{duration:600}):console.warning("trying to zoom non existing layer",a.id)};netgis.Map.prototype.onMapZoomLevel=function(a){this.view.setZoom(a.detail.z)};netgis.Map.prototype.onMapViewPrev=function(a){this.gotoViewHistory(this.viewIndex-1)};netgis.Map.prototype.onMapViewNext=function(a){this.gotoViewHistory(this.viewIndex+1)};
|
||||
netgis.Map.prototype.onMapLayerToggle=function(a){a=a.detail;switch(a.id){case netgis.LayerID.EDITABLE:a.on?this.map.addLayer(this.editLayer):this.map.removeLayer(this.editLayer);break;case netgis.LayerID.NON_EDITABLE:a.on?this.map.addLayer(this.nonEditLayer):this.map.removeLayer(this.nonEditLayer);break;default:if(a.on)for(var b=this.config.layers,c=0;c<b.length;c++){var d=b[c];d.id===a.id&&this.addLayer(a.id,d)}else this.removeLayer(a.id)}};
|
||||
netgis.Map.prototype.onMapLayerTransparency=function(a){a=a.detail;var b=this.layers[a.id];b||(netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:a.id,on:!0}),b=this.layers[a.id]);b.setOpacity(1-a.transparency)};netgis.Map.prototype.onMapSnapToggle=function(a){this.setSnapping(a.detail.on)};
|
||||
netgis.Map.prototype.onMapMoveEnd=function(a){a=this.view.getCenter();var b=this.view.getZoom(),c=this.getScaleFromResolution(this.view.getResolution());!1===this.viewFromHistory&&this.addViewHistory(a,b);netgis.util.invoke(this.container,netgis.Events.MAP_VIEW_CHANGE,{center:a,zoom:b,scale:c});this.viewFromHistory=!1};
|
||||
netgis.Map.prototype.onPointerMove=function(a){var b=a.pixel;a=a.coordinate;var c=null,d=null,e=void 0,f=this;this.map.forEachFeatureAtPixel(b,function(a,b){if(b&&b!==f.nonEditLayer)if(b===f.boundsLayer)e=a;else return c=a,d=b,!0});switch(this.mode){case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.updateDrawBufferPreview()}!this.boundsLayer||this.mode!==netgis.Modes.DRAW_POINTS&&this.mode!==netgis.Modes.DRAW_LINES&&this.mode!==netgis.Modes.DRAW_POLYGONS||(e?this.container.classList.remove("netgis-not-allowed"):
|
||||
this.container.classList.add("netgis-not-allowed"),this.hoverBounds=e);var g=!0;this.mode===netgis.Modes.VIEW&&(g=!1);this.mode===netgis.Modes.DRAW_POINTS&&(g=!1);this.mode===netgis.Modes.DRAW_LINES&&(g=!1);this.mode===netgis.Modes.DRAW_POLYGONS&&(g=!1);this.mode===netgis.Modes.CUT_FEATURES_DRAW&&(g=!1);if(c!==this.hoverFeature&&g){if(this.hoverFeature)this.onFeatureLeave(this.hoverFeature,this.hoverLayer,b,a);if(c)this.onFeatureEnter(c,d,b,a);this.redrawVectorLayers();this.hoverFeature=c;this.hoverLayer=
|
||||
d}if(c)this.onFeatureHover(c,d,b,a)};netgis.Map.prototype.onPointerLeave=function(a){this.hoverFeature&&(this.onFeatureLeave(this.hoverFeature,this.hoverLayer,[a.offsetX,a.offsetY],null),this.hoverLayer=this.hoverFeature=null)};
|
||||
netgis.Map.prototype.onPointerClick=function(a){var b=a.pixel;a=a.coordinate;this.popupOverlay.setPosition(a);var c=[],d=this;this.map.forEachFeatureAtPixel(b,function(a,b){b&&b!==d.nonEditLayer&&b!==d.boundsLayer&&b!==d.measureLayer&&b!==d.previewLayer&&c.push({feature:a,layer:b})});var e=!0;this.mode===netgis.Modes.VIEW&&(e=!1);this.mode===netgis.Modes.DRAW_POINTS&&(e=!1);this.mode===netgis.Modes.DRAW_LINES&&(e=!1);this.mode===netgis.Modes.DRAW_POLYGONS&&(e=!1);this.mode===netgis.Modes.CUT_FEATURES_DRAW&&
|
||||
(e=!1);0<c.length&&!1===this.selectMultiple&&e&&(this.selectedFeatures=[]);for(var f=0;f<c.length;f++){var g=c[f];e&&this.selectedFeatures.push(g.feature);this.onFeatureClick(g.feature,g.layer,b,a)}e={resolution:this.view.getResolution(),projection:this.view.getProjection().getCode(),bbox:this.view.calculateExtent(this.map.getSize()),width:this.map.getSize()[0],height:this.map.getSize()[1]};f=ol.proj.toLonLat(a,this.view.getProjection());b={mode:this.mode,pixel:b,coords:a,lon:f[0],lat:f[1],overlay:this.popupOverlay.getElement(),
|
||||
view:e};netgis.util.invoke(this.container,netgis.Events.MAP_CLICK,b);this.redrawVectorLayers()};netgis.Map.prototype.onRightClick=function(a){switch(this.mode){case netgis.Modes.MEASURE_LINE:this.interactions[netgis.Modes.MEASURE_LINE][2].finishDrawing();break;case netgis.Modes.MEASURE_AREA:this.interactions[netgis.Modes.MEASURE_AREA][2].finishDrawing()}a.preventDefault();return!1};
|
||||
netgis.Map.prototype.onKeyDown=function(a){a=a.keyCode||a.which;switch(this.mode){case netgis.Modes.MEASURE_LINE:13===a&&this.interactions[netgis.Modes.MEASURE_LINE][2].finishDrawing();27===a&&this.interactions[netgis.Modes.MEASURE_LINE][2].abortDrawing();break;case netgis.Modes.MEASURE_AREA:13===a&&this.interactions[netgis.Modes.MEASURE_AREA][2].finishDrawing();27===a&&this.interactions[netgis.Modes.MEASURE_AREA][2].abortDrawing();break;case netgis.Modes.DRAW_LINES:var b=this.interactions[netgis.Modes.DRAW_LINES][0];
|
||||
13===a&&b.finishDrawing();27===a&&b.abortDrawing();8===a&&b.removeLastPoint();46===a&&b.abortDrawing();break;case netgis.Modes.DRAW_POLYGONS:b=this.interactions[netgis.Modes.DRAW_POLYGONS][0],13===a&&b.finishDrawing(),27===a&&b.abortDrawing(),8===a&&b.removeLastPoint(),46===a&&b.abortDrawing()}16===a&&(this.selectMultiple=!0)};
|
||||
netgis.Map.prototype.onPointerMove=function(a){var b=a.pixel;a=a.coordinate;var c=null,d=null,e=void 0,f=this;this.map.forEachFeatureAtPixel(b,function(a,b){if(b&&b!==f.measureLayer&&b!==f.nonEditLayer)if(b===f.boundsLayer)e=a;else if(b!==f.previewLayer)return c=a,d=b,!0});switch(this.mode){case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.updateDrawBufferPreview()}if(this.boundsLayer&&(this.mode===netgis.Modes.DRAW_POINTS||this.mode===netgis.Modes.DRAW_LINES||this.mode===netgis.Modes.DRAW_POLYGONS)){if(e)this.container.classList.remove("netgis-not-allowed"),
|
||||
this.container.removeAttribute("title");else{this.container.classList.add("netgis-not-allowed");var g=this.config.tools.bounds_message;g&&0<g.length&&this.container.setAttribute("title",g)}this.hoverBounds=e}g=!0;this.mode===netgis.Modes.VIEW&&(g=!1);this.mode===netgis.Modes.MEASURE_LINE&&(g=!1);this.mode===netgis.Modes.MEASURE_AREA&&(g=!1);this.mode===netgis.Modes.DRAW_POINTS&&(g=!1);this.mode===netgis.Modes.DRAW_LINES&&(g=!1);this.mode===netgis.Modes.DRAW_POLYGONS&&(g=!1);this.mode===netgis.Modes.CUT_FEATURES_DRAW&&
|
||||
(g=!1);if(c!==this.hoverFeature&&g){if(this.hoverFeature)this.onFeatureLeave(this.hoverFeature,this.hoverLayer,b,a);if(c)this.onFeatureEnter(c,d,b,a);this.redrawVectorLayers();this.hoverFeature=c;this.hoverLayer=d}if(c)this.onFeatureHover(c,d,b,a)};netgis.Map.prototype.onPointerLeave=function(a){this.hoverFeature&&(this.onFeatureLeave(this.hoverFeature,this.hoverLayer,[a.offsetX,a.offsetY],null),this.hoverLayer=this.hoverFeature=null)};
|
||||
netgis.Map.prototype.onPointerClick=function(a){var b=a.pixel;a=a.coordinate;this.popupOverlay.setPosition(a);var c=[],d=this;this.map.forEachFeatureAtPixel(b,function(a,b){b&&b!==d.nonEditLayer&&b!==d.boundsLayer&&b!==d.measureLayer&&b!==d.previewLayer&&(-1<d.sketchFeatures.indexOf(a)||c.push({feature:a,layer:b}))});var e=!0;this.mode===netgis.Modes.VIEW&&(e=!1);this.mode===netgis.Modes.MEASURE_LINE&&(e=!1);this.mode===netgis.Modes.MEASURE_AREA&&(e=!1);this.mode===netgis.Modes.DRAW_POINTS&&(e=!1);
|
||||
this.mode===netgis.Modes.DRAW_LINES&&(e=!1);this.mode===netgis.Modes.DRAW_POLYGONS&&(e=!1);this.mode===netgis.Modes.CUT_FEATURES_DRAW&&(e=!1);e&&(0<c.length&&!1===this.selectMultiple&&(this.selectedFeatures=[]),0===c.length&&!1===this.selectMultiple&&(this.selectedFeatures=[]),this.mode===netgis.Modes.BUFFER_FEATURES_DYNAMIC&&this.updateBufferFeaturesSketch(this.bufferFeaturesRadius,this.bufferFeaturesSegments));for(var f=0;f<c.length;f++){var g=c[f];if(e){var h=this.selectedFeatures.indexOf(g.feature);
|
||||
-1<h?this.selectedFeatures.splice(h,1):this.selectedFeatures.push(g.feature)}this.onFeatureClick(g.feature,g.layer,b,a)}e={resolution:this.view.getResolution(),projection:this.view.getProjection().getCode(),bbox:this.view.calculateExtent(this.map.getSize()),width:this.map.getSize()[0],height:this.map.getSize()[1]};f=ol.proj.toLonLat(a,this.view.getProjection());b={mode:this.mode,pixel:b,coords:a,lon:f[0],lat:f[1],overlay:this.popupOverlay.getElement(),view:e};netgis.util.invoke(this.container,netgis.Events.MAP_CLICK,
|
||||
b);this.redrawVectorLayers()};netgis.Map.prototype.onContainerClick=function(a){if(2===a.detail)this.onDoubleClick(a)};
|
||||
netgis.Map.prototype.onDoubleClick=function(a){switch(this.mode){case netgis.Modes.MEASURE_LINE:this.interactions[netgis.Modes.MEASURE_LINE][2].finishDrawing();break;case netgis.Modes.MEASURE_AREA:this.interactions[netgis.Modes.MEASURE_AREA][2].finishDrawing();break;case netgis.Modes.DRAW_LINES:this.interactions[netgis.Modes.DRAW_LINES][0].finishDrawing();break;case netgis.Modes.DRAW_POLYGONS:this.interactions[netgis.Modes.DRAW_POLYGONS][0].finishDrawing();break;case netgis.Modes.CUT_FEATURES_DRAW:this.interactions[netgis.Modes.CUT_FEATURES_DRAW][0].finishDrawing()}};
|
||||
netgis.Map.prototype.onRightClick=function(a){switch(this.mode){case netgis.Modes.MEASURE_LINE:this.interactions[netgis.Modes.MEASURE_LINE][2].finishDrawing();break;case netgis.Modes.MEASURE_AREA:this.interactions[netgis.Modes.MEASURE_AREA][2].finishDrawing();break;case netgis.Modes.DRAW_LINES:this.interactions[netgis.Modes.DRAW_LINES][0].finishDrawing();break;case netgis.Modes.DRAW_POLYGONS:this.interactions[netgis.Modes.DRAW_POLYGONS][0].finishDrawing();break;case netgis.Modes.CUT_FEATURES_DRAW:this.interactions[netgis.Modes.CUT_FEATURES_DRAW][0].finishDrawing()}a.preventDefault();
|
||||
return!1};
|
||||
netgis.Map.prototype.onKeyDown=function(a){a=a.keyCode||a.which;switch(this.mode){case netgis.Modes.MEASURE_LINE:13===a&&this.interactions[netgis.Modes.MEASURE_LINE][2].finishDrawing();27===a&&this.interactions[netgis.Modes.MEASURE_LINE][2].abortDrawing();break;case netgis.Modes.MEASURE_AREA:13===a&&this.interactions[netgis.Modes.MEASURE_AREA][2].finishDrawing();27===a&&this.interactions[netgis.Modes.MEASURE_AREA][2].abortDrawing();break;case netgis.Modes.DRAW_LINES:var b=this.interactions[netgis.Modes.DRAW_LINES][0];13===
|
||||
a&&b.finishDrawing();27===a&&b.abortDrawing();8===a&&b.removeLastPoint();46===a&&b.abortDrawing();break;case netgis.Modes.DRAW_POLYGONS:b=this.interactions[netgis.Modes.DRAW_POLYGONS][0];13===a&&b.finishDrawing();27===a&&b.abortDrawing();8===a&&b.removeLastPoint();46===a&&b.abortDrawing();break;case netgis.Modes.CUT_FEATURES_DRAW:b=this.interactions[netgis.Modes.CUT_FEATURES_DRAW][0],13===a&&b.finishDrawing(),27===a&&b.abortDrawing(),8===a&&b.removeLastPoint(),46===a&&b.abortDrawing(),16===a&&netgis.util.invoke(this.container,
|
||||
netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES})}16===a&&(this.selectMultiple=!0)};
|
||||
netgis.Map.prototype.onKeyUp=function(a){a=a.keyCode||a.which;switch(this.mode){case netgis.Modes.BUFFER_FEATURES:this.selectMultiple&&netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES_EDIT});break;case netgis.Modes.CUT_FEATURES:this.selectMultiple&&netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES_DRAW})}16===a&&(this.selectMultiple=!1)};
|
||||
netgis.Map.prototype.onFeatureEnter=function(a,b,c,d){if(b){switch(this.mode){case netgis.Modes.DELETE_FEATURES:case netgis.Modes.BUFFER_FEATURES:case netgis.Modes.CUT_FEATURES:this.container.classList.add("netgis-clickable");a.setStyle(this.styleHover.bind(this));break;case netgis.Modes.SEARCH_PARCEL:this.container.classList.add("netgis-clickable"),a.setStyle(this.styleHover.bind(this))}netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_ENTER,{pixel:c,coords:d,layer:b.get("id"),properties:a.getProperties()})}};
|
||||
netgis.Map.prototype.onFeatureHover=function(a,b,c,d){};
|
||||
netgis.Map.prototype.onFeatureEnter=function(a,b,c,d){if(b){switch(this.mode){case netgis.Modes.DELETE_FEATURES:case netgis.Modes.BUFFER_FEATURES:case netgis.Modes.BUFFER_FEATURES_DYNAMIC:case netgis.Modes.CUT_FEATURES:this.container.classList.add("netgis-clickable");a.setStyle(this.styleHover.bind(this));break;case netgis.Modes.SEARCH_PARCEL:this.container.classList.add("netgis-clickable"),a.setStyle(this.styleHover.bind(this))}netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_ENTER,{pixel:c,
|
||||
coords:d,layer:b.get("id"),properties:a.getProperties()})}};netgis.Map.prototype.onFeatureHover=function(a,b,c,d){};
|
||||
netgis.Map.prototype.onFeatureClick=function(a,b,c,d){c={pixel:c,coords:d,layer:this.hoverLayer?this.hoverLayer.get("id"):null,id:this.hoverFeature?this.hoverFeature.getId():null,properties:this.hoverFeature?this.hoverFeature.getProperties():null};netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_CLICK,c);switch(this.mode){case netgis.Modes.DELETE_FEATURES:b.getSource().removeFeature(a);this.onFeatureLeave(a,b);netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW});
|
||||
break;case netgis.Modes.BUFFER_FEATURES:this.onFeatureLeave(a,b);this.selectMultiple||netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES_EDIT});break;case netgis.Modes.CUT_FEATURES:if(a.getGeometry()instanceof ol.geom.Point)this.onFeatureLeave(a,b);else this.selectMultiple||netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES_DRAW})}};
|
||||
netgis.Map.prototype.onFeatureLeave=function(a,b,c,d){netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_LEAVE,{pixel:c,coords:d,layer:b?b.get("id"):null,properties:a.getProperties()});switch(this.mode){case netgis.Modes.DELETE_FEATURES:case netgis.Modes.BUFFER_FEATURES:case netgis.Modes.CUT_FEATURES:case netgis.Modes.CUT_FEATURES_DRAW:this.container.classList.remove("netgis-clickable");a.setStyle(null);break;case netgis.Modes.SEARCH_PARCEL:this.container.classList.remove("netgis-clickable"),
|
||||
break;case netgis.Modes.BUFFER_FEATURES:case netgis.Modes.BUFFER_FEATURES_EDIT:this.onFeatureLeave(a,b);this.selectMultiple?netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES}):netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.BUFFER_FEATURES_EDIT});break;case netgis.Modes.BUFFER_FEATURES_DYNAMIC:this.updateBufferFeaturesSketch(this.bufferFeaturesRadius,this.bufferFeaturesSegments);break;case netgis.Modes.CUT_FEATURES:if(a.getGeometry()instanceof
|
||||
ol.geom.Point)this.onFeatureLeave(a,b);else this.selectMultiple||netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.CUT_FEATURES_DRAW})}};
|
||||
netgis.Map.prototype.onFeatureLeave=function(a,b,c,d){netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_LEAVE,{pixel:c,coords:d,layer:b?b.get("id"):null,properties:a.getProperties()});switch(this.mode){case netgis.Modes.DELETE_FEATURES:case netgis.Modes.BUFFER_FEATURES:case netgis.Modes.BUFFER_FEATURES_DYNAMIC:case netgis.Modes.CUT_FEATURES:case netgis.Modes.CUT_FEATURES_DRAW:this.container.classList.remove("netgis-clickable");a.setStyle(null);break;case netgis.Modes.SEARCH_PARCEL:this.container.classList.remove("netgis-clickable"),
|
||||
a.setStyle(null)}};netgis.Map.prototype.onEditLayerAdd=function(a){this.editEventsSilent||this.updateEditOutput();this.snapFeatures.push(a.feature)};netgis.Map.prototype.onEditLayerRemove=function(a){this.editEventsSilent||this.updateEditOutput();this.snapFeatures.remove(a.feature)};netgis.Map.prototype.onEditLayerChange=function(a){this.editEventsSilent||this.updateEditOutput()};
|
||||
netgis.Map.prototype.onCopyFeatureToEdit=function(a){a=a.detail;var b=this.layers[a.source].getSource().getFeatureById(a.id);b?this.editLayer.getSource().getFeatureById(a.id)||(b.setStyle(void 0),this.selectedFeatures=[],this.editLayer.getSource().addFeature(b)):console.error("feature to copy not found",a)};netgis.Map.prototype.onMeasureLineBegin=function(a){this.measureLayer.getSource().clear()};netgis.Map.prototype.onMeasureAreaBegin=function(a){this.measureLayer.getSource().clear()};
|
||||
netgis.Map.prototype.onMeasureClear=function(a){this.measureLayer.getSource().clear()};
|
||||
netgis.Map.prototype.onDrawBufferEnd=function(a){var b=a.feature;a=this.previewLayer.getSource().getFeatures();if(0!==a.length){a=a[0];if(this.boundsLayer){var c=!0;c=b.getGeometry()instanceof ol.geom.Point?this.isPointInsideLayer(this.boundsLayer,b.getGeometry().getCoordinates()):this.isGeomInsideLayer(this.boundsLayer,b.getGeometry());if(!c)return;c=new jsts.io.OL3Parser;for(var d=c.read(a.getGeometry()),e=this.boundsLayer.getSource().getFeatures(),f=0;f<e.length;f++){var g=c.read(e[f].getGeometry());
|
||||
d.intersects(g)&&(d=d.intersection(g))}c=c.write(d);a.setGeometry(c)}var h=this.editLayer.getSource();h.addFeature(a.clone());window.setTimeout(function(){h.removeFeature(b)},10)}};netgis.Map.prototype.onDrawBufferToggle=function(a){a=a.detail;this.setDrawBuffer(a.on,a.radius,a.segments)};netgis.Map.prototype.onDrawBufferChange=function(a){a=a.detail;this.drawBufferRadius=a.radius;this.drawBufferSegments=a.segments;this.updateDrawBufferPreview()};
|
||||
netgis.Map.prototype.onBufferChange=function(a){a=a.detail;var b=this.selectedFeatures,c=this.editLayer.getSource();this.clearSketchFeatures();for(var d=0;d<b.length;d++){var e=this.createBufferFeature(this.selectedFeatures[d].getGeometry(),a.radius,a.segments);c.addFeature(e);this.sketchFeatures.push(e)}};
|
||||
netgis.Map.prototype.onBufferChange=function(a){a=a.detail;this.updateBufferFeaturesSketch(a.radius,a.segments);this.bufferFeaturesRadius=a.radius;this.bufferFeaturesSegments=a.segments};netgis.Map.prototype.updateBufferFeaturesSketch=function(a,b){var c=this.selectedFeatures,d=this.editLayer.getSource();this.clearSketchFeatures();for(var e=0;e<c.length;e++){var f=this.createBufferFeature(this.selectedFeatures[e].getGeometry(),a,b);d.addFeature(f);this.sketchFeatures.push(f)}};
|
||||
netgis.Map.prototype.onBufferAccept=function(a){a=this.selectedFeatures;for(var b=this.editLayer.getSource(),c=0;c<a.length;c++)b.removeFeature(a[c]);this.sketchFeatures=[];this.selectedFeatures=[]};
|
||||
netgis.Map.prototype.onCutFeaturesDrawEnd=function(a){a=a.feature;for(var b=0;b<this.selectedFeatures.length;b++){var c=this.selectedFeatures[b];if(c)if(this.onFeatureLeave(c,null),c.getGeometry()instanceof ol.geom.Point)console.error("trying to cut a point feature",c);else{var d=new jsts.io.OL3Parser,e=d.read(c.getGeometry()),f=d.read(a.getGeometry());e=e.difference(f);d=d.write(e);d=new ol.Feature({geometry:d});e=this.editLayer.getSource();e.removeFeature(c);e.addFeature(d)}}this.selectedFeatures=
|
||||
[];this.editEventsSilent=!0;this.splitMultiPolygons(this.editLayer);this.editEventsSilent=!1;this.updateEditOutput();netgis.util.invoke(this.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW})};netgis.Map.prototype.onImportLayerAccept=function(a){a=a.detail;a=this.addLayer(a.id,a);0!==a.getSource().getFeatures().length&&this.view.fit(a.getSource().getExtent(),{duration:600})};netgis.Map.prototype.onImportGeoportalSubmit=function(a){};
|
||||
@ -265,24 +280,26 @@ netgis.Map.prototype.onSearchParcelItemLeave=function(a){a=a.detail.id;this.laye
|
||||
netgis.Map.prototype.onDrawLinesUpdateGeom=function(a,b,c){b?b.setCoordinates(a):b=new ol.geom.LineString(a);this.drawError=!this.isGeomInsideLayer(this.boundsLayer,b);return b};
|
||||
netgis.Map.prototype.onDrawPolygonsUpdateGeom=function(a,b,c){b?(a=[a[0].concat([a[0][0]])],b.setCoordinates(a)):b=new ol.geom.Polygon(a);c=!0;if(4>a[0].length)for(var d=0;d<a[0].length;d++){if(!this.isPointInsideLayer(this.boundsLayer,a[0][d])){c=!1;break}}else c=this.isGeomInsideLayer(this.boundsLayer,b);this.drawError=!c;return b};
|
||||
netgis.Map.prototype.onDrawPointsEnd=function(a){if(this.boundsLayer){var b=a.feature,c=this.editLayer;this.isPointInsideLayer(this.boundsLayer,b.getGeometry().getCoordinates())||window.setTimeout(function(){c.getSource().removeFeature(b)},10)}};netgis.Map.prototype.onDrawLinesEnd=function(a){if(this.boundsLayer){var b=a.feature,c=this.editLayer;this.isGeomInsideLayer(this.boundsLayer,b.getGeometry())||window.setTimeout(function(){c.getSource().removeFeature(b)},10)}};
|
||||
netgis.Map.prototype.onDrawPolygonsEnd=function(a){if(this.boundsLayer){var b=a.feature,c=this.editLayer;this.isGeomInsideLayer(this.boundsLayer,b.getGeometry())||window.setTimeout(function(){c.getSource().removeFeature(b)},10)}};netgis.Map.prototype.onExportBegin=function(a){a=a.detail;switch(a.format){case "geojson":this.exportFeatures(a.nonEdits);break;default:this.exportImage(a.format,a.width,a.height,a.landscape,a.padding)}};netgis.Map.prototype.onTimeSliderShow=function(a){};
|
||||
netgis.Map.prototype.onTimeSliderHide=function(a){};netgis.Map.prototype.onTimeSliderSelect=function(a){a=a.detail;console.info("Time Slider Select:",a);this.layers[a.layer].getSource().updateParams({TIME:a.time})};netgis=netgis||{};netgis.Menu=function(a){this.config=a;this.initElements();this.initConfig(a)};
|
||||
netgis.Map.prototype.onDrawPolygonsEnd=function(a){if(this.boundsLayer){var b=a.feature,c=this.editLayer;this.isGeomInsideLayer(this.boundsLayer,b.getGeometry())||window.setTimeout(function(){c.getSource().removeFeature(b)},10)}};netgis.Map.prototype.onExportBegin=function(a){a=a.detail;switch(a.format){case "geojson":this.exportFeatures(a.nonEdits);break;default:this.exportImage(a.format,a.width,a.height,a.landscape,a.padding)}};
|
||||
netgis.Map.prototype.onScalebarSelectChange=function(a){a=this.scalebarSelect.value;console.info("Scalebar Click:",this.scalebar,a);netgis.util.invoke(this.scalebarSelect,netgis.Events.MAP_ZOOM_SCALE,{scale:a,anim:!0})};netgis.Map.prototype.onTimeSliderShow=function(a){};netgis.Map.prototype.onTimeSliderHide=function(a){};netgis.Map.prototype.onTimeSliderSelect=function(a){a=a.detail;console.info("Time Slider Select:",a);this.layers[a.layer].getSource().updateParams({TIME:a.time})};netgis=netgis||{};netgis.Menu=function(a){this.config=a;this.initElements();this.initConfig(a)};
|
||||
netgis.Menu.prototype.initElements=function(){this.container=document.createElement("nav");this.container.className="netgis-menu netgis-noselect netgis-color-a netgis-shadow-large";this.toggle=document.createElement("button");this.toggle.setAttribute("type","button");this.toggle.addEventListener("click",this.onToggleClick.bind(this));this.toggle.className="netgis-menu-toggle netgis-hover-c";this.toggle.innerHTML="<i class='fas fa-bars'></i>";this.container.appendChild(this.toggle)};
|
||||
netgis.Menu.prototype.initConfig=function(a){!0===a.menu.compact&&this.container.classList.add("netgis-compact");this.addHeader(a.menu.header);for(var b=a.menu.items,c=0;c<b.length;c++){var d=b[c];if(d.items)this.addDropdown(d.title,d.items);else if(d.url&&0<d.url.length)this.addLink(d.url,d.title);else if(d.options){var e;if("scales"===d.options){var f={0:"1:X"};for(e=0;e<a.map.scales.length;e++)f[a.map.scales[e]]="1:"+a.map.scales[e];e=a.map.default_scale;this.addSelect(d.id,d.title,f,e).options[0].classList.add("netgis-hide")}else{f=
|
||||
d.options;if(d.value)e=d.value;else for(var g in f){e=g;break}this.addSelect(d.id,d.title,f,e)}}else this.addButton(d.id,d.title)}};netgis.Menu.prototype.attachTo=function(a){a.appendChild(this.container);a.addEventListener(netgis.Events.MAP_VIEW_CHANGE,this.onMapViewChange.bind(this))};netgis.Menu.prototype.addHeader=function(a){var b=document.createElement("h1");b.className="netgis-hover-c";b.innerHTML=a;this.container.appendChild(b);return b};
|
||||
netgis.Menu.prototype.addButton=function(a,b){a=this.createButton(a,b);this.container.appendChild(a);return a};netgis.Menu.prototype.addLink=function(a,b){a=this.createLink(a,b);this.container.appendChild(a);return a};
|
||||
netgis.Menu.prototype.addSelect=function(a,b,c,d){var e=document.createElement("span");e.className="netgis-wrapper netgis-hover-c";var f=document.createElement("select");f.setAttribute("data-id",a);for(var g in c){a=c[g];var h=document.createElement("option");h.setAttribute("value",g);h.innerHTML=a;f.appendChild(h)}f.value=d;f.addEventListener("change",this.onSelectChange.bind(this));e.appendChild(f);b&&(c=document.createElement("span"),c.className="netgis-icon",c.innerHTML=b,e.appendChild(c));this.container.appendChild(e);
|
||||
return f};netgis.Menu.prototype.addDropdown=function(a,b){var c=document.createElement("div");c.className="netgis-dropdown netgis-hover-c";var d=document.createElement("button");d.setAttribute("type","button");d.innerHTML=a;c.appendChild(d);a=document.createElement("ul");a.className="netgis-color-e netgis-shadow";c.appendChild(a);for(d=0;d<b.length;d++)a.appendChild(this.createMenuItem(b[d]));this.container.appendChild(c);return c};
|
||||
netgis.Menu.prototype.createMenuItem=function(a){var b=document.createElement("li");b.className="netgis-hover-c";if(a.items)a=this.createMenu(a.title,a.items),b.appendChild(a.button),b.appendChild(a.list);else if(a.type)switch(a.type){case "checkbox":a=this.createCheckbox(a.id,a.title,a.value);b.appendChild(a);break;default:console.error("unhandled menu item type",a.type,"for",a.id)}else a.url?(a=this.createLink(a.url,a.title),b.appendChild(a)):(a=this.createButton(a.id,a.title),b.appendChild(a));
|
||||
return b};netgis.Menu.prototype.createMenu=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.addEventListener("pointerdown",this.onButtonClick.bind(this));c.innerHTML=a;a=document.createElement("ul");a.className="netgis-color-e netgis-shadow";for(var d=0;d<b.length;d++)a.appendChild(this.createMenuItem(b[d]));return{button:c,list:a}};
|
||||
netgis.Menu.prototype.createMenuItem=function(a){var b=document.createElement("li");b.className="netgis-hover-c";var c=a.items;if("scales"===a.id)for(var d=this.config.map.scales,e=0;e<d.length;e++)c.push({id:netgis.Commands.ZOOM_SCALE,title:"1:"+d[e]});if(c&&0<c.length)a=this.createMenu(a.title,c),b.appendChild(a.button),b.appendChild(a.list);else if(a.type)switch(a.type){case "checkbox":a=this.createCheckbox(a.id,a.title,a.value);b.appendChild(a);break;default:console.error("unhandled menu item type",
|
||||
a.type,"for",a.id)}else a.url?(a=this.createLink(a.url,a.title),b.appendChild(a)):(a=this.createButton(a.id,a.title),b.appendChild(a));return b};netgis.Menu.prototype.createMenu=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.addEventListener("pointerdown",this.onButtonClick.bind(this));c.innerHTML=a;a=document.createElement("ul");a.className="netgis-color-e netgis-shadow";for(var d=0;d<b.length;d++)a.appendChild(this.createMenuItem(b[d]));return{button:c,list:a}};
|
||||
netgis.Menu.prototype.createLink=function(a,b){var c=document.createElement("a");c.setAttribute("href",a);c.setAttribute("target","_blank");c.classList="netgis-button";c.innerHTML=b;return c};netgis.Menu.prototype.createButton=function(a,b){var c=document.createElement("button");c.className="netgis-text-e netgis-hover-c";c.setAttribute("type","button");c.setAttribute("data-id",a);c.addEventListener("pointerdown",this.onButtonClick.bind(this));c.innerHTML=b;return c};
|
||||
netgis.Menu.prototype.createCheckbox=function(a,b,c){var d=document.createElement("label");d.className="netgis-button";var e=document.createElement("input");e.setAttribute("type","checkbox");e.setAttribute("data-id",a);e.addEventListener("change",this.onCheckboxChange.bind(this));e.checked=c;d.appendChild(e);a=document.createElement("span");a.innerHTML=b;d.appendChild(a);return d};netgis.Menu.prototype.onToggleClick=function(a){this.container.classList.toggle("netgis-menu-large")};
|
||||
netgis.Menu.prototype.onButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.MENU_BUTTON_CLICK,{id:b});netgis.Client.handleCommand(a,b)};
|
||||
netgis.Menu.prototype.onCheckboxChange=function(a){a=a.currentTarget;var b=a.getAttribute("data-id"),c=a.checked;netgis.util.invoke(a,netgis.Events.MENU_CHECKBOX_CHANGE,{id:b,checked:c});switch(b){case netgis.Menu.ItemID.SNAP_TOGGLE:netgis.util.invoke(a,netgis.Events.MAP_SNAP_TOGGLE,{on:c});break;default:console.error("unhandled menu item id",b)}};
|
||||
netgis.Menu.prototype.onSelectChange=function(a){a=a.currentTarget;var b=a.getAttribute("data-id"),c=a.value;netgis.util.invoke(a,netgis.Events.MENU_SELECT_CHANGE,{id:b,value:c});switch(b){case "scales":netgis.util.invoke(a,netgis.Events.MAP_ZOOM_SCALE,{scale:Number.parseInt(c)})}};
|
||||
netgis.Menu.prototype.onMapViewChange=function(a){a=a.detail;for(var b=this.container.getElementsByTagName("select"),c=0;c<b.length;c++){var d=b[c];if("scales"===!d.getAttribute("data-id"))break;for(var e=!1,f=this.config.map.scales,g=0;g<f.length;g++)if(f[g]===a.scale){e=!0;break}e?d.options[0].classList.add("netgis-hide"):(d.options[0].setAttribute("value",a.scale),d.options[0].innerHTML="1:"+a.scale,d.options[0].classList.remove("netgis-hide"));d.value=a.scale}};netgis=netgis||{};netgis.Modal=function(a){this.initElements(a);this.initEvents()};netgis.Modal.prototype.initElements=function(a){this.container=document.createElement("div");this.container.className="netgis-modal";this.container.addEventListener("click",this.onContainerClick.bind(this));this.content=document.createElement("div");this.content.className="netgis-color-e netgis-shadow";this.container.appendChild(this.content);this.header=this.addHeader(this.content,a,this.onHeaderClick.bind(this))};
|
||||
netgis.Menu.prototype.onMapViewChange=function(a){a=a.detail;for(var b=a.scale,c=this.container.getElementsByTagName("button"),d=0;d<c.length;d++){var e=c[d];"zoom_scale"===e.getAttribute("data-id")&&(Number.parseInt(e.innerText.split(":")[1])===b?e.classList.add("netgis-bold"):e.classList.remove("netgis-bold"))}c=this.container.getElementsByTagName("select");for(d=0;d<c.length;d++){e=c[d];if("scales"===!e.getAttribute("data-id"))break;for(var f=!1,g=this.config.map.scales,h=0;h<g.length;h++)if(g[h]===
|
||||
b){f=!0;break}f?e.options[0].classList.add("netgis-hide"):(e.options[0].setAttribute("value",a.scale),e.options[0].innerHTML="1:"+a.scale,e.options[0].classList.remove("netgis-hide"));e.value=b}};netgis=netgis||{};netgis.Modal=function(a){this.initElements(a);this.initEvents()};netgis.Modal.prototype.initElements=function(a){this.container=document.createElement("div");this.container.className="netgis-modal";this.container.addEventListener("click",this.onContainerClick.bind(this));this.content=document.createElement("div");this.content.className="netgis-color-e netgis-shadow";this.container.appendChild(this.content);this.header=this.addHeader(this.content,a,this.onHeaderClick.bind(this))};
|
||||
netgis.Modal.prototype.initEvents=function(){};netgis.Modal.prototype.attachTo=function(a){a.appendChild(this.container)};netgis.Modal.prototype.show=function(){this.container.classList.add("netgis-show")};netgis.Modal.prototype.hide=function(){this.container.classList.remove("netgis-show")};
|
||||
netgis.Modal.prototype.addHeader=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-clip-text netgis-color-c";d.innerHTML="<span>"+b+"</span><i class='netgis-icon fas fa-times'></i>";d.setAttribute("type","button");c&&(d.onclick=c);a&&a.appendChild(d);return d};netgis.Modal.prototype.onHeaderClick=function(a){this.hide()};netgis.Modal.prototype.onContainerClick=function(a){a.target===this.container&&this.hide()};netgis=netgis||{};netgis.Modes=Object.freeze({VIEW:"view",ZOOM_BOX:"zoom-box",MEASURE_LINE:"measure-line",MEASURE_AREA:"measure-area",DRAW_POINTS:"draw-points",DRAW_LINES:"draw-lines",DRAW_POLYGONS:"draw-polygons",MODIFY_FEATURES:"modify-features",DELETE_FEATURES:"delete-features",BUFFER_FEATURES:"buffer-features",BUFFER_FEATURES_EDIT:"buffer-features-edit",CUT_FEATURES:"cut-features",CUT_FEATURES_DRAW:"cut-features-draw",SEARCH_PARCEL:"search-parcel"});netgis=netgis||{};
|
||||
netgis.Modal.prototype.addHeader=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-clip-text netgis-color-c";d.innerHTML="<span>"+b+"</span><i class='netgis-icon fas fa-times'></i>";d.setAttribute("type","button");c&&(d.onclick=c);a&&a.appendChild(d);return d};netgis.Modal.prototype.onHeaderClick=function(a){this.hide()};netgis.Modal.prototype.onContainerClick=function(a){a.target===this.container&&this.hide()};netgis=netgis||{};
|
||||
netgis.Modes=Object.freeze({VIEW:"view",ZOOM_BOX:"zoom-box",MEASURE_LINE:"measure-line",MEASURE_AREA:"measure-area",DRAW_POINTS:"draw-points",DRAW_LINES:"draw-lines",DRAW_POLYGONS:"draw-polygons",MODIFY_FEATURES:"modify-features",DELETE_FEATURES:"delete-features",BUFFER_FEATURES:"buffer-features",BUFFER_FEATURES_EDIT:"buffer-features-edit",BUFFER_FEATURES_DYNAMIC:"buffer-features-dynamic",CUT_FEATURES:"cut-features",CUT_FEATURES_DRAW:"cut-features-draw",CUT_FEATURES_DYNAMIC:"cut-features-dynamic",SEARCH_PARCEL:"search-parcel"});netgis=netgis||{};
|
||||
netgis.OWS=function(){return{read:function(a,b){b={layers:[],folders:[]};netgis.util.isDefined(a.properties)&&(b.bbox=a.properties.bbox);a=a.features;for(var c=0;c<a.length;c++){var d=a[c];if("Feature"===d.type){var e=d.properties;e=e.folder;var f=!1;for(d=0;d<b.folders.length;d++)if(b.folders[d].id===e){f=!0;break}if(!f){d=e.split("/");e=[];for(f=0;f<d.length;f++){var g=d[f];0<g.length&&e.push(g)}var h=-1;for(f=0;f<e.length;f++){g=e[f];var k="/"+e.slice(0,f+1).join("/"),l=!1;for(d=0;d<b.folders.length;d++)if(b.folders[d].path===
|
||||
k){h=d;l=!0;break}l||(d=b.folders.length,b.folders.push({title:g,parent:h,path:k}),h=d)}}}}for(c=0;c<a.length;c++)if(d=a[c],"Feature"===d.type){e=d.properties;f=-1;for(d=0;d<b.folders.length;d++)if(b.folders[d].path===e.folder){f=d;break}d=e.offerings;for(g=0;g<d.length;g++)switch(h=d[g],k=h.operations,h.code){case "http://www.opengis.net/spec/owc-geojson/1.0/req/wms":b.layers.push({folder:f,type:netgis.LayerTypes.WMS,url:k[0].href,title:e.title,attribution:e.rights,active:e.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/xyz":h=
|
||||
k[0];b.layers.push({folder:f,type:netgis.LayerTypes.XYZ,url:h.href,title:e.title,attribution:e.rights,active:e.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/osm":h=k[0],b.layers.push({folder:f,type:netgis.LayerTypes.XYZ,url:h.href,title:e.title,attribution:e.rights,active:e.active})}}return b}}}();netgis=netgis||{};netgis.Panel=function(a){this.initElements(a);this.initEvents()};netgis.Panel.prototype.initElements=function(a){var b=document.createElement("section");b.className="netgis-panel netgis-resize-right netgis-color-e netgis-shadow";this.content=document.createElement("div");b.appendChild(this.content);this.header=this.addHeader(b,a,this.onHeaderClick.bind(this));this.container=b};netgis.Panel.prototype.initEvents=function(){this.resizeObserver=(new ResizeObserver(this.onResize.bind(this))).observe(this.container)};
|
||||
@ -358,7 +375,7 @@ c.addEventListener("click",this.onHeaderButtonClick.bind(this));c.className="net
|
||||
netgis.Tabs.prototype.setActiveTab=function(a){for(var b=this.header.getElementsByClassName("netgis-button"),c=this.content.getElementsByTagName("section"),d=0;d<b.length;d++){var e=b[d],f=c[d];d===a?(e.classList.add("netgis-color-e"),e.classList.add("netgis-text-a"),e.classList.add("netgis-bar-a"),e.classList.add("netgis-active"),e.scrollIntoView({behavior:"smooth"}),f.classList.remove("netgis-hide"),f.scrollTop=0):(e.classList.remove("netgis-color-e"),e.classList.remove("netgis-text-a"),e.classList.remove("netgis-bar-a"),
|
||||
e.classList.remove("netgis-active"),f.classList.add("netgis-hide"))}};netgis.Tabs.prototype.getContentSection=function(a){return this.content.getElementsByTagName("section")[a]};netgis.Tabs.prototype.appendContent=function(a,b){this.content.getElementsByTagName("section")[a].appendChild(b)};
|
||||
netgis.Tabs.prototype.updateHeaderScroll=function(){for(var a=0,b=this.header.getElementsByTagName("button"),c=0;c<b.length;c++){var d=b[c];a+=d.getBoundingClientRect().width;d.classList.contains("netgis-active")&&d.scrollIntoView()}b=this.header.getBoundingClientRect().width;a>b?this.container.classList.add("netgis-scroll"):this.container.classList.remove("netgis-scroll")};
|
||||
netgis.Tabs.prototype.onHeaderButtonClick=function(a){a=a.currentTarget;for(var b=this.header.getElementsByClassName("netgis-button"),c=0,d=0;d<b.length;d++)if(b[d]===a){c=d;break}this.setActiveTab(c)};netgis=netgis||{};netgis.TimeSlider=function(a){this.config=a;this.insertTop=!0;this.initElements();for(a=1900;2E3>=a;a++);console.info("TimeSlider:",this);var b=this;window.setTimeout(function(){b.container.scrollLeft=0},1)};
|
||||
netgis.Tabs.prototype.onHeaderButtonClick=function(a){a=a.currentTarget;for(var b=this.header.getElementsByClassName("netgis-button"),c=0,d=0;d<b.length;d++)if(b[d]===a){c=d;break}this.setActiveTab(c)};netgis=netgis||{};netgis.TimeSlider=function(a){this.config=a;this.insertTop=!0;this.initElements();for(a=1900;2E3>=a;a++);var b=this;window.setTimeout(function(){b.container.scrollLeft=0},1)};
|
||||
netgis.TimeSlider.prototype.initElements=function(){this.container=document.createElement("section");this.container.className="netgis-timeslider netgis-footer netgis-noselect netgis-color-e netgis-hide";document.addEventListener("pointermove",this.onPointerMove.bind(this));document.addEventListener("pointerup",this.onPointerUp.bind(this));this.header=document.createElement("button");this.header.className="netgis-header netgis-button netgis-clip-text netgis-color-a netgis-hover-c netgis-shadow";this.header.innerHTML=
|
||||
"<i class='netgis-icon fas fa-clock'></i><span>TimeSlider</span><i class='netgis-icon fas fa-times'></i>";this.header.setAttribute("type","button");this.header.addEventListener("click",this.onHeaderClick.bind(this));this.container.appendChild(this.header);this.wrapper=document.createElement("div");this.wrapper.className="netgis-wrapper";this.wrapper.addEventListener("pointerdown",this.onPointerDown.bind(this));this.container.appendChild(this.wrapper);this.table=document.createElement("table");this.wrapper.appendChild(this.table);
|
||||
this.top=document.createElement("tr");this.table.appendChild(this.top);this.bottom=document.createElement("tr")};netgis.TimeSlider.prototype.attachTo=function(a){a.appendChild(this.container);a.addEventListener(netgis.Events.TIMESLIDER_SHOW,this.onTimeSliderShow.bind(this));a.addEventListener(netgis.Events.TIMESLIDER_HIDE,this.onTimeSliderHide.bind(this))};
|
||||
@ -393,9 +410,9 @@ c[2].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"))};netgis.Too
|
||||
netgis.Toolbox.prototype.onLayerTreeToggle=function(a){this.panel.hide()};netgis.Toolbox.prototype.onSearchParcelToggle=function(a){this.panel.hide()};
|
||||
netgis.Toolbox.prototype.onClientSetMode=function(a){a=a.detail;this.hideBottom();switch(a.mode){default:this.setActiveButton(null);break;case netgis.Modes.VIEW:this.setActiveButton(netgis.Commands.VIEW);break;case netgis.Modes.ZOOM_BOX:this.setActiveButton(netgis.Commands.ZOOM_BOX);break;case netgis.Modes.MEASURE_LINE:this.setActiveButton(netgis.Commands.MEASURE_LINE);break;case netgis.Modes.MEASURE_AREA:this.setActiveButton(netgis.Commands.MEASURE_AREA);break;case netgis.Modes.DRAW_POINTS:this.setActiveButton(netgis.Commands.DRAW_POINTS);
|
||||
this.showBottom(this.bottomPanels.drawPoints,"Punkte zeichnen");break;case netgis.Modes.DRAW_LINES:this.setActiveButton(netgis.Commands.DRAW_LINES);this.showBottom(this.bottomPanels.drawLines,"Linien zeichnen");break;case netgis.Modes.DRAW_POLYGONS:this.setActiveButton(netgis.Commands.DRAW_POLYGONS);this.showBottom(this.bottomPanels.drawPolygons,"Polygone zeichnen");break;case netgis.Modes.MODIFY_FEATURES:this.setActiveButton(netgis.Commands.MODIFY_FEATURES);this.showBottom(this.bottomPanels.modifyFeatures,
|
||||
"Verschieben");break;case netgis.Modes.DELETE_FEATURES:this.setActiveButton(netgis.Commands.DELETE_FEATURES);break;case netgis.Modes.BUFFER_FEATURES:this.setActiveButton(netgis.Commands.BUFFER_FEATURES);this.showBottom(this.bottomPanels.bufferFeatures,"Puffern");break;case netgis.Modes.BUFFER_FEATURES_EDIT:this.setActiveButton(netgis.Commands.BUFFER_FEATURES);this.showBottom(this.bottomPanels.bufferFeatures,"Puffern");this.onBufferFeaturesChange();break;case netgis.Modes.CUT_FEATURES:case netgis.Modes.CUT_FEATURE_DRAW:this.setActiveButton(netgis.Commands.CUT_FEATURES)}};
|
||||
netgis.Toolbox.prototype.onTopResize=function(a){if(!this.bottom.classList.contains("netgis-hide")){a=this.top.getBoundingClientRect();var b=this.top.parentNode.getBoundingClientRect();this.bottom.style.top=a.bottom-b.top+"px"}};netgis.Toolbox.prototype.onBottomHeaderClick=function(a){netgis.util.invoke(this.panel.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW})};
|
||||
netgis.Toolbox.prototype.onButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.TOOLBOX_BUTTON_CLICK,{id:b});netgis.Client.handleCommand(a,b)};
|
||||
"Verschieben");break;case netgis.Modes.DELETE_FEATURES:this.setActiveButton(netgis.Commands.DELETE_FEATURES);break;case netgis.Modes.BUFFER_FEATURES:this.setActiveButton(netgis.Commands.BUFFER_FEATURES);this.showBottom(this.bottomPanels.bufferFeatures,"Puffern");this.onBufferFeaturesChange();break;case netgis.Modes.BUFFER_FEATURES_EDIT:this.setActiveButton(netgis.Commands.BUFFER_FEATURES);this.showBottom(this.bottomPanels.bufferFeatures,"Puffern");this.onBufferFeaturesChange();break;case netgis.Modes.BUFFER_FEATURES_DYNAMIC:this.setActiveButton(netgis.Commands.BUFFER_FEATURES);
|
||||
this.showBottom(this.bottomPanels.bufferFeatures,"Puffern");this.onBufferFeaturesChange();break;case netgis.Modes.CUT_FEATURES:case netgis.Modes.CUT_FEATURE_DRAW:this.setActiveButton(netgis.Commands.CUT_FEATURES)}};netgis.Toolbox.prototype.onTopResize=function(a){if(!this.bottom.classList.contains("netgis-hide")){a=this.top.getBoundingClientRect();var b=this.top.parentNode.getBoundingClientRect();this.bottom.style.top=a.bottom-b.top+"px"}};
|
||||
netgis.Toolbox.prototype.onBottomHeaderClick=function(a){netgis.util.invoke(this.panel.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW})};netgis.Toolbox.prototype.onButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.TOOLBOX_BUTTON_CLICK,{id:b});netgis.Client.handleCommand(a,b)};
|
||||
netgis.Toolbox.prototype.onDrawSnapToggle=function(a){var b=a.currentTarget,c=b.parentNode.parentNode;a=b.checked;netgis.util.invoke(b,netgis.Events.MAP_SNAP_TOGGLE,{on:a});b=[];c===this.bottomPanels.drawPoints&&(b.push(this.bottomPanels.drawLines),b.push(this.bottomPanels.drawPolygons),b.push(this.bottomPanels.modifyFeatures));c===this.bottomPanels.drawLines&&(b.push(this.bottomPanels.drawPoints),b.push(this.bottomPanels.drawPolygons),b.push(this.bottomPanels.modifyFeatures));c===this.bottomPanels.drawPolygons&&
|
||||
(b.push(this.bottomPanels.drawPoints),b.push(this.bottomPanels.drawLines),b.push(this.bottomPanels.modifyFeatures));c===this.bottomPanels.modifyFeatures&&(b.push(this.bottomPanels.drawPoints),b.push(this.bottomPanels.drawLines),b.push(this.bottomPanels.drawPolygons));for(c=0;c<b.length;c++)b[c].getElementsByTagName("input")[0].checked=a};
|
||||
netgis.Toolbox.prototype.onDrawBufferToggle=function(a){a=a.currentTarget;var b=a.checked;this.showDrawBufferOptions(b);var c=this.bottomPanels.drawPoints.getElementsByTagName("input"),d=Number.parseFloat(c[2].value);c=Number.parseInt(c[3].value);netgis.util.invoke(a,netgis.Events.DRAW_BUFFER_TOGGLE,{on:b,radius:d,segments:c})};
|
||||
@ -429,13 +446,13 @@ b);a=this.replace(a,"\u00b5",b);a=this.trim(a,b);a=this.replace(a,"\u00e4","ae")
|
||||
b.innerHTML=a;return b.children[0]},size:function(a){a=(new TextEncoder).encode(JSON.stringify(a)).length;var b=a/1024;return{bytes:a,kilobytes:b,megabytes:b/1024}},request:function(a,b,e){var c=new XMLHttpRequest;e&&(c._requestData=e);c.onload=function(){b(this.responseText,this._requestData,this)};c.withCredentials=!1;c.open("GET",a,!0);c.send();return c},downloadJSON:function(a,b){a="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(a));var c=document.createElement("a");c.setAttribute("href",
|
||||
a);c.setAttribute("download",b);document.body.appendChild(c);c.click();c.remove()},padstr:function(a,b){for(a=a.toString();a.length<b;)a="0"+a;return a},merge:function(a,b){return Object.assign(a,b)},getTimeStamp:function(a){var b=new Date;if(!0===a){a=b.getFullYear();var c=b.getMonth()+1,f=b.getDate(),g=b.getHours(),h=b.getMinutes();b=b.getSeconds();10>c&&(c="0"+c);10>f&&(f="0"+f);10>g&&(g="0"+g);10>h&&(h="0"+h);10>b&&(b="0"+b);a=[a,c,f,"_",g,h,b].join("")}else a=b.getDate()+"."+(b.getMonth()+1)+
|
||||
"."+b.getFullYear(),a+=" "+b.getHours()+":"+b.getMinutes();return a},getUserLanguage:b,getFileExtension:function(a){a=a.split(".");return 1>=a.length?"":a[a.length-1]},formatDistance:function(a){return 100<a?Math.round(a/1E3*100)/100+" km":Math.round(100*a)/100+" m"},formatLength:function(a,b){var c=1E3<a;a=c?b?Math.round(a/1E3*1E3)/1E3:Math.round(a/1E3):b?Math.round(100*a)/100:Math.round(a);0===a&&(c=!1);return a+(c?" km":" m")},formatArea:function(a,d,e,f){a=(e=a>(e||1E5))?d?Math.round(a/1E6*1E3)/
|
||||
1E3:Math.round(a/1E6):d?Math.round(100*a)/100:Math.round(a);0===a&&(e=!1);a=a.toLocaleString(b());return a+(e?" km\u00b2":" m\u00b2")},invoke:function(a,b,e){a.dispatchEvent(new CustomEvent(b,{bubbles:!0,detail:e}))},handler:function(a,b){return function(c){b||(b=c);netgis.util.invoke(this,a,b)}}}}();netgis=netgis||{};netgis.WMC=function(){};netgis.WMC.prototype.requestContext=function(a,b){this.callback=b;netgis.util.request(a,this.onContextResponse.bind(this))};netgis.WMC.prototype.onContextResponse=function(a){a=JSON.parse(a);this.fromJSON(a)};netgis.WMC.prototype.requestLayers=function(a){a="./proxy.php?https://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?languageCode=de&resultTarget=web&maxResults=40&resourceIds="+a.join(",");netgis.util.request(a,this.onLayersResponse.bind(this))};
|
||||
1E3:Math.round(a/1E6):d?Math.round(100*a)/100:Math.round(a);0===a&&(e=!1);a=a.toLocaleString(b());return a+(e?" km\u00b2":" m\u00b2")},hexToRGB:function(a){"#"===a.charAt(0)&&(a=a.substr(1));a=Number.parseInt(a,16);return[a>>16&255,a>>8&255,a&255]},invoke:function(a,b,e){a.dispatchEvent(new CustomEvent(b,{bubbles:!0,detail:e}))},handler:function(a,b){return function(c){b||(b=c);netgis.util.invoke(this,a,b)}}}}();netgis=netgis||{};netgis.WMC=function(){};netgis.WMC.prototype.requestContext=function(a,b){this.callback=b;netgis.util.request(a,this.onContextResponse.bind(this))};netgis.WMC.prototype.onContextResponse=function(a){a=JSON.parse(a);this.fromJSON(a)};netgis.WMC.prototype.requestLayers=function(a){a="./proxy.php?https://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?languageCode=de&resultTarget=web&maxResults=40&resourceIds="+a.join(",");netgis.util.request(a,this.onLayersResponse.bind(this))};
|
||||
netgis.WMC.prototype.onLayersResponse=function(a){a=JSON.parse(a).wms.srv;this.services=[];for(var b=0;b<a.length;b++){var c=a[b],d={id:c.id,title:c.title,url:c.getMapUrl};d.layers=this.parseLayers(c.layer);this.services.push(d)}var e=this.layers;this.services.sort(function(a,b){a=Number.parseInt(a.layers[0].id);b=Number.parseInt(b.layers[0].id);for(var c=null,d=null,f=0;f<e.length;f++)e[f].id===a&&(c=f),e[f].id===b&&(d=f);return c<d?-1:c>d?1:0});this.callback&&this.callback({config:this.toConfig()})};
|
||||
netgis.WMC.prototype.parseLayers=function(a){var b=[];if(a)for(var c=0;c<a.length;c++){var d=a[c],e={id:d.id,title:d.title,name:d.name,legendURL:d.getLegendGraphicUrl,legendFormat:d.getLegendGraphicUrlFormat,queryable:d.layerQueryable|d.queryable,bbox:d.bbox};e.layers=this.parseLayers(d.layer);b.push(e)}this.sortLayers(b);return b};
|
||||
netgis.WMC.prototype.sortLayers=function(a){var b=this.layers;a.sort(function(a,d){var c=null,f=null;a=Number.parseInt(a.id);d=Number.parseInt(d.id);for(var g=0;g<b.length;g++)b[g].id===a&&(c=b[g].pos),b[g].id===d&&(f=b[g].pos);return c<f?1:c>f?-1:0})};
|
||||
netgis.WMC.prototype.fromJSON=function(a){var b=a.wmc;this.id=b.id;this.title=b.title;this.crs=b.crs;var c=b.bbox;c=c.split(",");for(b=0;b<c.length;b++)c[b]=Number.parseFloat(c[b]);this.bbox=c;this.layers=[];c=[];a=a.layerList;for(b=0;b<a.length;b++){var d=a[b];this.layers.push({id:d.layerId,active:d.active,opacity:d.opacity,pos:d.layerPos});c.push(d.layerId)}this.requestLayers(c)};
|
||||
netgis.WMC.prototype.toConfig=function(){for(var a={map:{attribution:this.title+", GeoPortal RLP",projection:this.crs,bbox:this.bbox}},b=[],c=[],d=this.layers.length,e=0;e<this.services.length;e++){var f=this.services[e],g=f.layers[0],h={id:g.id,title:g.title,parent:-1};b.unshift(h);h=h.id;for(var k=0;k<g.layers.length;k++){for(var l=g.layers[k],m=null,n=0;n<this.layers.length;n++)if(this.layers[n].id===Number.parseInt(l.id)){m=this.layers[n];break}c.push({id:l.id,title:l.title,folder:h,active:m.active,
|
||||
type:"WMS",url:f.url,name:l.name,order:d});--d}}a.folders=b;a.layers=c;return a};netgis=netgis||{};netgis.WMC=function(){};netgis.WMC.prototype.requestContext=function(a,b){this.callback=b;netgis.util.request(a,this.onContextResponse.bind(this))};netgis.WMC.prototype.onContextResponse=function(a){a=JSON.parse(a);console.info("Context Response:",a);this.fromJSON(a)};
|
||||
netgis.WMC.prototype.fromJSON=function(a){var b=a.wmc;this.id=b.id;this.title=b.title;this.crs=b.crs;var c=b.bbox;c=c.split(",");for(var d=0;d<c.length;d++)c[d]=Number.parseFloat(c[d]);this.bbox=c;this.layers=[];c=[];a=a.layerList;for(d=0;d<a.length;d++){var e=a[d];this.layers.push({id:e.layerId,active:e.active,opacity:e.opacity,pos:e.layerPos});c.push(e.layerId)}this.requestLayers(c);this.kmloverlay=b.kmloverlay};
|
||||
netgis.WMC.prototype.toConfig=function(){var a={map:{attribution:this.title+", GeoPortal RLP",projection:this.crs,bbox:this.bbox}},b=[],c=[];if(this.kmloverlay&&""!==this.kmloverlay){var d={id:"kmloverlay",title:"KML",parent:null};b.push(d);var e={id:"kmloverlay",folder:"kmloverlay",title:"KML Overlay",active:!0,order:9999,type:netgis.LayerTypes.KML,url:this.kmloverlay};c.push(e)}for(var f=this.layers.length,g=0;g<this.services.length;g++){var h=this.services[g],k=h.layers[0];d={id:k.id,title:k.title,
|
||||
parent:-1};b.unshift(d);d=d.id;for(var l=0;l<k.layers.length;l++){e=k.layers[l];for(var m=null,n=0;n<this.layers.length;n++)if(this.layers[n].id===Number.parseInt(e.id)){m=this.layers[n];break}e={id:e.id,title:e.title,folder:d,active:m.active,type:"WMS",url:h.url,name:e.name,order:f};c.push(e);--f}}a.folders=b;a.layers=c;return a};netgis=netgis||{};netgis.WMC=function(){};netgis.WMC.prototype.requestContext=function(a,b){this.callback=b;netgis.util.request(a,this.onContextResponse.bind(this))};netgis.WMC.prototype.onContextResponse=function(a){a=JSON.parse(a);console.info("Context Response:",a);this.fromJSON(a)};
|
||||
netgis.WMC.prototype.requestLayers=function(a){a="./proxy.php?https://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?languageCode=de&resultTarget=web&maxResults=40&resourceIds="+a.join(",");netgis.util.request(a,this.onLayersResponse.bind(this))};
|
||||
netgis.WMC.prototype.onLayersResponse=function(a){a=JSON.parse(a);console.info("Layers Response:",a);a=a.wms.srv;this.services=[];for(var b=0;b<a.length;b++){var c=a[b],d={id:c.id,title:c.title,url:c.getMapUrl};d.layers=this.parseLayers(c.layer);this.services.push(d)}var e=this.layers;this.services.sort(function(a,b){a=Number.parseInt(a.layers[0].id);b=Number.parseInt(b.layers[0].id);for(var c=null,d=null,f=0;f<e.length;f++)e[f].id===a&&(c=f),e[f].id===b&&(d=f);return c<d?-1:c>d?1:0});this.callback&&
|
||||
this.callback({config:this.toConfig()})};netgis.WMC.prototype.parseLayers=function(a){var b=[];if(a)for(var c=0;c<a.length;c++){var d=a[c],e={id:d.id,title:d.title,name:d.name,legendURL:d.getLegendGraphicUrl,legendFormat:d.getLegendGraphicUrlFormat,queryable:d.layerQueryable|d.queryable,bbox:d.bbox};e.layers=this.parseLayers(d.layer);b.push(e)}this.sortLayers(b);return b};
|
||||
|
Loading…
Reference in New Issue
Block a user