LANIS Update:

-> compiled build + demo for LANIS only
-> geoportal / mobilemap + sources coming soon
-> config naming scheme changed to snake_case (see demo/lanis.html)
- container element attributes center lon, lat, zoom (overrides config)
- config layers / folders use id string instead of indices
- config folder radio buttons / single layer selection
- layer tree transparency sliders
- cut / buffer tool multi select features (shift + click)
- move vertex tool snapping
- config tools snapping (active, radius)
- draw tools config allowed area / bounds
- import initial geometry value as read-only (property "editable")
- import service check failing services / error alerts
- import geometry preview table / select features to load
- export geometry file of current drawing (geojson)
- map keep polygon area labels inside viewport
- fix: client read only mode ("data-editable=false")
This commit is contained in:
sebastianpauli 2024-10-24 15:10:58 +02:00
parent 2014ac31ad
commit 81fa3bef48
8 changed files with 1356 additions and 355 deletions

BIN
assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -11,25 +11,19 @@
<!-- Library Styles -->
<link rel="stylesheet" type="text/css" href="/libs/fontawesome/5.12.0/css/all.min.css" />
<link rel="stylesheet" type="text/css" href="/libs/openlayers/7.2.2/ol.css" />
<link rel="stylesheet" type="text/css" href="/libs/openlayers/10.0.0/ol.css" />
<!-- Custom Styles -->
<link rel="stylesheet" type="text/css" href="../src/netgis/Client.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Map.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Attribution.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Controls.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/LayerTree.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/SearchParcel.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Toolbar.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Menu.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Modal.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis/Theme.css" />
<!--<link rel="stylesheet" type="text/css" href="../dist/netgis.min.css" />-->
<link rel="stylesheet" type="text/css" href="../dist/netgis.min.css" />
<!-- Implementation Style -->
<style>
html, body
{
font-family: Arial, sans-serif;
}
#container
{
position: absolute;
@ -47,14 +41,16 @@
<!-- Client Container -->
<form action="." method="GET">
<main id="container" data-editable="true">
<main id="container" data-editable="true" data-lon="7.0" data-lat="50.0" data-zoom="10">
</main>
</form>
<input type="hidden" id="netgis-storage" name="output" />
<input type="hidden" id="netgis-storage" name="output" value='' />
<!-- Library Scripts -->
<script type="text/javascript" src="/libs/openlayers/7.2.2/ol.js"></script>
<script type="text/javascript" src="/libs/openlayers/10.0.0/ol.js"></script>
<script type="text/javascript" src="/libs/proj4js/2.6.0/proj4.js"></script>
<script type="text/javascript" src="/libs/jsts/1.6.1/jsts.min.js"></script>
<script type="text/javascript" src="/libs/shapefilejs/4.0.2/shp.js"></script>
@ -64,57 +60,41 @@
<script type="text/javascript" src="/libs/geopackage/4.2.3/geopackage.min.js"></script>
<!-- Custom Scripts -->
<script type="text/javascript" src="../src/netgis/Util.js"></script>
<script type="text/javascript" src="../src/netgis/Events.js"></script>
<script type="text/javascript" src="../src/netgis/Modes.js"></script>
<script type="text/javascript" src="../src/netgis/LayerTypes.js"></script>
<script type="text/javascript" src="../src/netgis/Client.js"></script>
<script type="text/javascript" src="../src/netgis/Menu.js"></script>
<script type="text/javascript" src="../src/netgis/Map.js"></script>
<script type="text/javascript" src="../src/netgis/MapOpenLayers.js"></script>
<script type="text/javascript" src="../src/netgis/Controls.js"></script>
<script type="text/javascript" src="../src/netgis/Attribution.js"></script>
<script type="text/javascript" src="../src/netgis/LayerTree.js"></script>
<script type="text/javascript" src="../src/netgis/Toolbar.js"></script>
<script type="text/javascript" src="../src/netgis/Modal.js"></script>
<script type="text/javascript" src="../src/netgis/SearchPlace.js"></script>
<script type="text/javascript" src="../src/netgis/SearchParcel.js"></script>
<script type="text/javascript" src="../src/netgis/OWS.js"></script>
<script type="text/javascript" src="../src/netgis/SLD.js"></script>
<!--<script type="text/javascript" src="../dist/netgis.min.js"></script>-->
<script type="text/javascript" src="../dist/netgis.min.js"></script>
<!-- Implementation Script -->
<script type="text/javascript">
// Demo Config
// Client Config
var config =
{
"layers":
[
{ "folder": 0, "type": "WMS", "title": "KOM Punkte", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_p&", "name": "kom_p" },
{ "folder": 0, "type": "WMS", "title": "KOM Linien", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_l&", "name": "kom_l" },
{ "folder": 0, "type": "WMS", "title": "KOM Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_f&", "name": "kom_f" },
{ "folder": 1, "type": "WMS", "title": "Lagebezeichnungen", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Lagebezeichnungen" },
{ "folder": 1, "type": "WMS", "title": "Flurstücke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck", "username": "abc", "password": "123" },
{ "folder": 1, "type": "WMS", "title": "Gebäude / Bauwerke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "GebaeudeBauwerke" },
{ "folder": 1, "type": "WMS", "title": "Nutzung", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Nutzung", "active": false },
{ "folder": 2, "type": "WFS", "title": "Überschwemmungsgebiete WFS Test", "url": "http://213.139.159.34:80/geoserver/uesg/wfs?", "name": "uesg:uesg_gesetzlich", "outputFormat": "application/json" },
{ "folder": 3, "type": "WMS", "title": "TopPlusOpen", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "folder": 3, "type": "OSM", "title": "Open Street Map", "attribution": "OSM", "active": true, "minZoom": 1, "maxZoom": 20 }
],
"folders":
[
{ "title": "KOM Kompensationsmaßnahmen", "parent": -1 },
{ "title": "ALKIS Liegenschaften", "parent": -1 },
{ "title": "Test", "parent": -1 },
{ "title": "Hintergrund", "parent": -1 }
],
"modules":
{
"menu": true,
"layertree": true,
"map": true,
"controls": true,
"attribution": true,
"info": true,
"searchplace": true,
"searchparcel": true,
"toolbox": true,
"import": true,
"export": true
},
"menu":
{
"header": "<a href='.' target='_self'>LANIS Demo</a>",
"items":
[
{ "id": "searchplace", "title": "<i class='fas fa-search'></i><span>Suche</span>" },
{ "id": "searchparcel", "title": "<i class='fas fa-vector-square'></i><span>Flurstücke</span>" },
{ "id": "toolbox", "title": "<i class='fas fa-tools'></i><span>Werkzeuge</span>" },
{ "id": "layertree", "title": "<i class='fas fa-layer-group'></i><span>Inhalte</span>" }
]
},
"projections":
[
[ "EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs" ]
@ -123,100 +103,287 @@
"map":
{
"projection": "EPSG:25832",
"center": [ 385000, 5543000 ],
"minZoom": 5,
"maxZoom": 19,
"zoom": 8,
"attribution": "LANIS RLP"
},
"output":
{
"id": "netgis-storage"
},
"search":
{
"url": "./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}"
//"bbox": [ 382906.15384615 + 25, 5585300 + 40, 389613.84615385 + 25, 5589660 + 40 ] // Zoom To Extent
//"center": [ 329766.1782104631, 5513621.076679279 ], // Zoom To Coordinates In Map Projection
"center_lonlat": [ 7.0, 51.0 ],
"zoom": 12,
"min_zoom": 5,
"max_zoom": 19,
"scalebar": true
},
"searchParcel":
"folders":
[
{ "id": "kom", "title": "KOM Kompensationsmaßnahmen (gesperrt)", "parent": null },
{ "id": "alkis", "title": "ALKIS Liegenschaften (Zoom)", "parent": null },
{ "id": "test", "title": "Test", "parent": null, "radio": false },
{ "id": "bg", "title": "Hintergrund", "parent": null, "radio": true }
],
"layers":
[
{ "id": "kom_points", "folder": "kom", "type": "WMS", "title": "KOM Punkte", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_p&", "name": "kom_p" },
{ "id": "kom_lines","folder": "kom", "type": "WMS", "title": "KOM Linien", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_l&", "name": "kom_l" },
{ "id": "kom_polygons","folder": "kom", "type": "WMS", "title": "KOM Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_f&", "name": "kom_f" },
{ "id": "fwfs", "folder": "test", "order": 10, "minZoom": 17, "active": false, "type": "WFS", "title": "Flurstücke WFS", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/ajax/get_alkis.php?mytab=flurstuecke&", "name": "flurstuecke", "format": "application/json" },
{ "id": "lika", "folder": "alkis", "type": "WMS", "active": false, "title": "LIKA", "url": "https://www.geoportal.rlp.de/owsproxy/kvfrelpv6226orl6961pge6q0f/85fd2a2e2b058ab4a6b0a9c331b07246?", "name": "lika", "order": 1100 },
{ "id": "lk", "folder": "alkis", "type": "WMS", "active": false, "title": "Landkreise", "url": "https://geo5.service24.rlp.de/wms/verwaltungsgrenzen_rp.fcgi", "name": "Landkreise", "order": 1100 },
{ "id": "geb", "folder": "alkis", "type": "WMS", "active": false, "title": "Gebäude / Bauwerke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "GebaeudeBauwerke", "order": 1000, "transparency": 0.3, "query_url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?service=WMS&version=1.1.0&request=GetFeatureInfo&styles=&layers=GebaeudeBauwerke&query_layers=GebaeudeBauwerke&bbox={bbox}&srs={proj}&width={width}&height={height}&x={x}&y={y}&info_format=" },
{ "id": "topo", "folder": "test", "active": false, "order": 1, "type": "WMS", "title": "Topo WMS", "url": "https://ows.mundialis.de/services/service?", "name": "TOPO-WMS", "query_url": "https://ows.mundialis.de/services/service?service=WMS&version=1.1.0&request=GetFeatureInfo&styles=&layers=TOPO-WMS&query_layers=TOPO-WMS&bbox={bbox}&srs={proj}&width={width}&height={height}&x={x}&y={y}&info_format=" },
{ "id": "top_tiles", "folder": "bg", "order": 1, "type": "WMS", "tiled": true, "title": "TopPlusOpen Tiled", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "id": "top", "folder": "bg", "order": 1, "type": "WMS", "title": "TopPlusOpen", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "id": "osm_human", "folder": "bg", "type": "XYZ", "title": "OSM Humanitarian", "attribution": "OSM", "url": "https://{a-c}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png" },
{ "id": "osm", "folder": "bg", "active": true, "type": "OSM", "title": "Open Street Map", "attribution": "OSM", "order": 1, "min_zoom": 1, "max_zoom": 20 },
{ "id": "bg_aerial", "folder": "bg", "order": 1, "title": "Luftbild", "type": "WMS", "url": "https://geo4.service24.rlp.de/wms/dop_basis.fcgi", "tiled": true, "name": "rp_dop" },
{ "id": "bg_hybrid", "folder": "bg", "order": 1, "title": "Hybrid", "type": "TMS", "url": "https://www.geoportal.rlp.de/mapcache/tms/1.0.0/test@UTM32/{z}/{x}/{-y}.jpeg", "projection": "EPSG:25832", "extent": "map" }
],
"layertree":
{
"nameURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",
"parcelURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json"
"open": false,
"title": "Inhalte",
"buttons":
[
{ "id": "import_layer", "title": "<i class='netgis-icon fas fa-plus' style='font-size: 1em;'></i><span>Hinzufügen...</span>" }
]
},
"controls":
{
"buttons":
[
{ "id": "zoom_in", "icon": "<i class='fas fa-plus'></i>", "title": "Zoom +" },
{ "id": "zoom_out", "icon": "<i class='fas fa-minus'></i>", "title": "Zoom -" },
{ "id": "zoom_home", "icon": "<i class='fas fa-home'></i>", "title": "Anfangsausdehung" }
]
},
"searchplace":
{
"title": "Adresse...",
"url": "./proxy_raw.php?" + "https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG=4326&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={query}&name_startsWith={query}",
"zoom": 17,
"marker_color": "darkgray",
"marker_title": "Such-Ergebnis"
},
"searchparcel":
{
"open": false,
"name_url": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",
"parcel_url": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json",
"districts_service":
{
"type": "WFS",
"url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",
"name": "vermkv:gemarkungen_rlp",
"format": "application/json; subtype=geojson",
"min_zoom": 12
},
"fields_service":
{
"url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",
"name": "vermkv:fluren_rlp",
"filter_property": "gmkgnr"
}
},
"toolbox":
{
"open": false,
"items":
[
{ "id": "view", "title": "<i class='netgis-icon netgis-text-a fas fa-hand-paper'></i><span>Betrachten</span>" },
{ "id": "zoom_box", "title": "<i class='netgis-icon netgis-text-a fas fa-expand'></i><span>Zoom-Rechteck</span>" },
{ "id": "view_prev", "title": "<i class='netgis-icon netgis-text-a fas fa-step-backward'></i><span>Vorherige Ansicht</span>" },
{ "id": "view_next", "title": "<i class='netgis-icon netgis-text-a fas fa-step-forward'></i><span>Nächste Ansicht</span>" },
{ "id": "measure_line", "title": "<i class='netgis-icon netgis-text-a fas fa-ruler'></i><span>Strecke messen</span>" },
{ "id": "measure_area", "title": "<i class='netgis-icon netgis-text-a fas fa-ruler-combined'></i><span>Fläche messen</span>" },
{ "id": "measure_clear", "title": "<i class='netgis-icon netgis-text-a fas fa-trash-alt'></i><span>Messung löschen</span>" },
{ "id": "draw_points", "title": "<i class='netgis-icon netgis-text-a fas fa-map-marker-alt'></i><span>Punkte zeichnen</span>" },
{ "id": "draw_lines", "title": "<i class='netgis-icon netgis-text-a fas fa-minus'></i><span>Linien zeichnen</span>" },
{ "id": "draw_polygons", "title": "<i class='netgis-icon netgis-text-a fas fa-vector-square'></i><span>Polygone zeichnen</span>" },
{ "id": "modify_features", "title": "<i class='netgis-icon netgis-text-a fas fa-arrows-alt'></i><span>Verschieben</span>" },
{ "id": "delete_features", "title": "<i class='netgis-icon netgis-text-a fas fa-eraser'></i><span>Löschen</span>" },
{ "id": "buffer_features", "title": "<i class='netgis-icon netgis-text-a far fa-dot-circle'></i><span>Puffern</span>" },
{ "id": "cut_features", "title": "<i class='netgis-icon netgis-text-a fas fa-cut'></i><span>Ausschneiden</span>" },
{ "id": "import_layer", "title": "<i class='netgis-icon netgis-text-a fas fa-upload'></i><span>Importieren</span>" },
{ "id": "export", "title": "<i class='netgis-icon netgis-text-a fas fa-save'></i><span>Exportieren</span>" }
],
"options":
{
"buffer_features":
{
"title": "Puffern",
"items":
[
{ "id": "buffer_radius", "type": "integer", "title": "Radius (Meter)" },
{ "id": "buffer_segments", "type": "integer", "title": "Segmente" },
{ "id": "buffer_submit", "type": "button", "title": "<i class='netgis-icon netgis-text-a fas fa-arrow-circle-right'></i><span>Akzeptieren</span>" }
]
}
}
},
"import":
{
"geopackageLibURL": "/libs/geopackage/4.2.3/"
"title": "Ebene hinzufügen",
"preview": true,
"wms_options": [ "https://sgx.geodatenzentrum.de/wms_topplus_open" ],
"wfs_options": [ "http://213.139.159.34:80/geoserver/uesg/wfs" ],
//"wfs_proxy": "./proxy.php?",
"geopackage_lib": "/libs/geopackage/4.2.3/"
},
"export":
{
"title": "Exportieren",
"logo": "/geoportal/client/assets/logo.png",
"gifWebWorker": "/libs/gifjs/0.2.0/gif.worker.js",
"defaultFilename": "Export",
"defaultMargin": 10
"gif_worker": "/libs/gifjs/0.2.0/gif.worker.js",
"default_filename": "Export",
"default_margin": 10
},
"measure":
{
"line_color": "rgba( 255, 0, 0, 1.0 )",
"line_width": 3.0,
"line_dash": [ 5, 10 ],
"area_fill": "rgba( 255, 0, 0, 0.3 )",
"point_radius": 4.0,
"point_fill": "rgba( 255, 255, 255, 1.0 )",
"point_stroke": "rgba( 0, 0, 0, 1.0 )",
"text_color": "#871d33",
"text_back": "rgba( 255, 255, 255, 0.7 )"
},
"tools":
{
"editable": true,
"interactive_render": true,
"buffer":
{
"defaultRadius": 300,
"defaultSegments": 3
}
"default_radius": 300,
"default_segments": 3
},
"snapping":
{
"show": true,
"active": true,
"tolerance": 10
},
// Boundary Polygons GeoJSON For Drawing Tools:
//"bounds": '{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[385947.1733847084,5587420.133948028],[385924.7215815909,5587575.524501444],[385983.8340881849,5587720.975589848],[386108.3204437366,5587816.649279207],[386128.61293018516,5587825.002716699],[386287.15210903366,5587844.293282578],[386433.12464682607,5587779.495015839],[386525.16063342174,5587648.972319218],[386533.51636313583,5587625.702029063],[386546.62565086246,5587472.317275605],[386481.9349259469,5587332.625306874],[386356.47850408487,5587243.409712766],[386337.3796933098,5587236.249623489],[386187.71257841075,5587220.454999909],[386049.20810348407,5587279.329662044],[385956.72279009596,5587398.057006087],[385947.1733847084,5587420.133948028]]]},"properties":null},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[386993.0181936734,5587227.7525485065],[386633.3370473852,5587978.680763736],[386923.60604263534,5588546.60966601],[387617.727553016,5588420.403243283],[387642.9683352116,5587934.508515782],[387232.80562453216,5588029.163332827],[387333.7687533148,5587549.578926463],[387655.5887263095,5587530.647963054],[387377.9401221572,5586893.305528278],[386993.0181936734,5587227.7525485065]]]},"properties":null},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[385705.73830169474,5586685.064930778],[386551.3045052493,5587019.511951006],[386993.0181936734,5586697.685573051],[386658.57782958087,5586306.445662595],[385970.76651474915,5586173.928918731],[385705.73830169474,5586685.064930778]]]},"properties":null}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::25832"}},"area":1928455.8138341408}',
"show_bounds": true
},
"output":
{
"id": "netgis-storage"
},
"attribution":
{
"prefix": "LANIS"
},
"styles":
{
"editLayer":
"draw":
{
"fill": "rgba( 255, 0, 0, 0.5 )",
"stroke": "#ff0000",
"strokeWidth": 3,
"pointRadius": 6
"width": 3,
"radius": 6,
"viewport_labels": true // Try To Keep Polygon Labels In View
},
"non_edit":
{
"fill": "rgba( 80, 80, 80, 0.5 )",
"stroke": "#666666",
"width": 3,
"radius": 6,
"viewport_labels": true
},
"select":
{
"fill": "rgba( 0, 127, 255, 0.5 )",
"stroke": "#007fff",
"strokeWidth": 3,
"pointRadius": 6
"width": 3,
"radius": 6
},
"sketch":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
"width": 3,
"radius": 6
},
"error":
{
"fill": "rgba( 255, 0, 0, 0.5 )",
"stroke": "#ff0000",
"width": 3,
"radius": 6
},
"bounds":
{
"fill": "rgba( 0, 0, 0, 0.0 )",
"stroke": "#000000",
"width": 3,
"radius": 6
},
"modify":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
"fill": "rgba( 255, 127, 0, 0.5 )",
"stroke": "#ff7f00",
"width": 3,
"radius": 6
},
"parcel":
{
"fill": "rgba( 127, 255, 255, 0.5 )",
"stroke": "#7fffff",
"strokeWidth": 3
"fill": "rgba( 127, 0, 0, 0.0 )",
"stroke": "rgba( 127, 0, 0, 1.0 )",
"width": 1.5
},
"import":
{
"fill": "rgba( 0, 127, 255, 0.2 )",
"stroke": "rgba( 0, 127, 255, 1.0 )",
"width": 1.5
}
}
};
// Create Client Instance
var client = new netgis.Client( "container", config );
client.debug = true;
</script>
</body>
</html>
</html>

283
demo/lanis_old.html Normal file
View File

@ -0,0 +1,283 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>LANIS Demo | NetGIS Client</title>
<!-- Library Styles -->
<link rel="stylesheet" type="text/css" href="/libs/fontawesome/5.12.0/css/all.min.css" />
<link rel="stylesheet" type="text/css" href="/libs/openlayers/7.2.2/ol.css" />
<!-- Custom Styles -->
<link rel="stylesheet" type="text/css" href="../src/netgis3/Client.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Map.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Attribution.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Controls.css" />
<!--<link rel="stylesheet" type="text/css" href="../src/netgis3/LayerTree.css" />-->
<link rel="stylesheet" type="text/css" href="../src/netgis3/SearchParcel.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Toolbar.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Menu.css" />
<!--<link rel="stylesheet" type="text/css" href="../src/netgis3/Modal.css" />-->
<link rel="stylesheet" type="text/css" href="../src/netgis3/Panel.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Tree.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Modal.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Tabs.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/SearchPlace.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Toolbox.css" />
<link rel="stylesheet" type="text/css" href="../src/netgis3/Theme.css" />
<!--<link rel="stylesheet" type="text/css" href="../dist/netgis.min.css" />-->
<!-- Implementation Style -->
<style>
#container
{
position: absolute;
left: 0mm;
top: 0mm;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<!-- Client Container -->
<form action="." method="GET">
<main id="container" data-editable="true">
</main>
</form>
<input type="hidden" id="netgis-storage" name="output" value='' />
<!-- Library Scripts -->
<script type="text/javascript" src="/libs/openlayers/7.2.2/ol.js"></script>
<script type="text/javascript" src="/libs/proj4js/2.6.0/proj4.js"></script>
<script type="text/javascript" src="/libs/jsts/1.6.1/jsts.min.js"></script>
<script type="text/javascript" src="/libs/shapefilejs/4.0.2/shp.js"></script>
<script type="text/javascript" src="/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script type="text/javascript" src="/libs/gifjs/0.2.0/gif.js"></script>
<script type="text/javascript" src="/libs/sqljs/1.8.0/sql.js"></script>
<script type="text/javascript" src="/libs/geopackage/4.2.3/geopackage.min.js"></script>
<!-- Custom Scripts -->
<script type="text/javascript" src="../src/netgis3/Util.js"></script>
<script type="text/javascript" src="../src/netgis3/Events.js"></script>
<script type="text/javascript" src="../src/netgis3/Modes.js"></script>
<script type="text/javascript" src="../src/netgis3/LayerTypes.js"></script>
<script type="text/javascript" src="../src/netgis3/Client.js"></script>
<script type="text/javascript" src="../src/netgis3/Menu.js"></script>
<script type="text/javascript" src="../src/netgis3/MapOpenLayers.js"></script>
<script type="text/javascript" src="../src/netgis3/Controls.js"></script>
<script type="text/javascript" src="../src/netgis3/Attribution.js"></script>
<script type="text/javascript" src="../src/netgis3/Toolbar.js"></script>
<script type="text/javascript" src="../src/netgis3/SearchPlace.js"></script>
<script type="text/javascript" src="../src/netgis3/SearchParcel.js"></script>
<script type="text/javascript" src="../src/netgis3/OWS.js"></script>
<script type="text/javascript" src="../src/netgis3/SLD.js"></script>
<script type="text/javascript" src="../src/netgis3/Panel.js"></script>
<script type="text/javascript" src="../src/netgis3/Tree.js"></script>
<script type="text/javascript" src="../src/netgis3/Modal.js"></script>
<script type="text/javascript" src="../src/netgis3/Tabs.js"></script>
<script type="text/javascript" src="../src/netgis3/Toolbox.js"></script>
<!--<script type="text/javascript" src="../dist/netgis.min.js"></script>-->
<!-- Implementation Script -->
<script type="text/javascript">
// Demo Config
var config =
{
"layers":
[
{ "folder": 0, "type": "WMS", "title": "KOM Punkte", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_p&", "name": "kom_p" },
{ "folder": 0, "type": "WMS", "title": "KOM Linien", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_l&", "name": "kom_l" },
{ "folder": 0, "type": "WMS", "title": "KOM Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_f&", "name": "kom_f" },
{ "folder": 1, "type": "WMS", "title": "Lagebezeichnungen", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Lagebezeichnungen" },
{ "folder": 1, "type": "WMS", "title": "Flurstücke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck", "username": "abc", "password": "123" },
{ "folder": 1, "type": "WMS", "title": "Gebäude / Bauwerke", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "GebaeudeBauwerke" },
{ "folder": 1, "type": "WMS", "title": "Nutzung", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Nutzung", "active": false },
{ "folder": 2, "type": "WFS", "title": "Überschwemmungsgebiete WFS Test", "url": "http://213.139.159.34:80/geoserver/uesg/wfs?", "name": "uesg:uesg_gesetzlich", "format": "application/json", "fill": "rgba( 0, 0, 127, 0.3 )", "stroke": "rgba( 0, 0, 127, 1.0 )", "width": 3.0 },
{ "folder": 3, "order": 1, "type": "WMS", "tiled": true, "title": "TopPlusOpen Tiled", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "folder": 3, "order": 1, "type": "WMS", "title": "TopPlusOpen", "attribution": "BKG", "url": "https://sgx.geodatenzentrum.de/wms_topplus_open?", "name": "web", "active": false },
{ "folder": 3, "type": "XYZ", "title": "OSM Humanitarian", "attribution": "OSM", "url": "https://{a-c}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png" },
{ "folder": 3, "type": "OSM", "title": "Open Street Map", "attribution": "OSM", "active": true, "minZoom": 1, "maxZoom": 20 },
{ "folder": 1, "order": 10, "minZoom": 17, "active": true, "type": "WFS", "title": "Flurstücke WFS", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/ajax/get_alkis.php?mytab=flurstuecke&", "name": "flurstuecke", "format": "application/json" },
//{ "folder": 1, "order": 1, "minZoom": 10, "active": true, "type": "WFS", "title": "Gemarkungen WFS", "url": "https://www.geoportal.rlp.de/registry/wfs/314?VERSION=1.1.0", "name": "vermkv:gemarkungen_rlp", "format": "application/json" },
{ "folder": 1, "order": 10, "minZoom": 13, "maxZoom": 15, "active": false, "type": "WFS", "title": "Gemarkungen WFS", "url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?", "name": "vermkv:gemarkungen_rlp", "format": "application/json; subtype=geojson" },
{ "folder": 1, "order": 10, "minZoom": 15, "maxZoom": 17, "active": false, "type": "WFS", "title": "Fluren WFS", "url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?", "name": "vermkv:fluren_rlp", "format": "application/json; subtype=geojson" }
],
"folders":
[
{ "title": "KOM Kompensationsmaßnahmen (gesperrt)", "parent": -1 },
{ "title": "ALKIS Liegenschaften (Zoom)", "parent": -1 },
{ "title": "Test", "parent": -1 },
{ "title": "Hintergrund", "parent": -1 }
],
"projections":
[
[ "EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs" ]
],
"map":
{
"projection": "EPSG:25832",
//"center": [ 385000, 5543000 ],
//"center": [ 329766.1782104631, 5513621.076679279 ],
"center": [ 337984, 5521600 ], // WFS Test
"zoom": 18, // WFS Test
"minZoom": 5,
"maxZoom": 19,
//"zoom": 10, //17.2, //8,
"attribution": "LANIS RLP",
"scalebar": true
},
"output":
{
"id": "netgis-storage"
},
"search":
{
"url": "./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}"
},
"searchParcel":
{
"nameURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",
"parcelURL": "./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json",
"districts_service":
{
"type": "WFS",
"url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",
"name": "vermkv:gemarkungen_rlp",
"minZoom": 11
//"maxZoom": 17
},
"fields_service":
{
"url": "http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",
"name": "vermkv:fluren_rlp",
"filter_property": "gmkgnr"
}
},
"import":
{
"geopackageLibURL": "/libs/geopackage/4.2.3/"
},
"export":
{
"logo": "/geoportal/client/assets/logo.png",
"gifWebWorker": "/libs/gifjs/0.2.0/gif.worker.js",
"defaultFilename": "Export",
"defaultMargin": 10
},
"tools":
{
"buffer":
{
"defaultRadius": 300,
"defaultSegments": 3
}
},
"styles":
{
"editLayer":
{
"fill": "rgba( 255, 0, 0, 0.5 )",
"stroke": "#ff0000",
"strokeWidth": 3,
"pointRadius": 6
},
"select":
{
"fill": "rgba( 0, 127, 255, 0.5 )",
"stroke": "#007fff",
"strokeWidth": 3,
"pointRadius": 6
},
"sketch":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
},
"modify":
{
"fill": "rgba( 0, 127, 0, 0.5 )",
"stroke": "#007f00",
"strokeWidth": 3,
"pointRadius": 6
},
"parcel":
{
"fill": "rgba( 127, 0, 0, 0.0 )",
"stroke": "rgba( 127, 0, 0, 1.0 )",
"width": 1.5
},
"import":
{
"fill": "rgba( 0, 127, 255, 0.2 )",
"stroke": "rgba( 0, 127, 255, 1.0 )",
"width": 1.5
}
}
};
// Test Config URL
//config = "../data/test_config.json";
// Test Geometry Loading
//document.getElementById( "netgis-storage" ).value = '{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[337849.169,5524000.603],[337726.657,5523930.41],[337739.148,5523873.992],[337748.991,5523853.693],[337765.084,5523794.539],[337770.91,5523776.333],[337782.049,5523755.893],[337798.246,5523730.319],[337822.829,5523691.506],[337829.532,5523684.213],[337832.313,5523681.81],[337839.396,5523675.69],[337843.284,5523672.33],[337882.707,5523640.5],[337892.398,5523641.593],[337900.558,5523648.451],[337911.526,5523671.198],[337926.551,5523694.042],[337935.302,5523706.151],[337951.722,5523737.095],[337984.658,5523794.887],[337973.018,5523807.091],[337957.732,5523829.219],[337942.789,5523861.88],[337925.967,5523895.597],[337884.361,5523939.382],[337859.855,5523977.099],[337849.169,5524000.603]]]},"properties":{"fln":"18","fsn_zae":"78","fsn_nen":"3","bbox":"POLYGON((337726.657 5523640.5,337726.657 5524000.603,337984.658 5524000.603,337984.658 5523640.5,337726.657 5523640.5))","X":337862.0171027997,"Y":5523818.154999999,"fsk":"072612018000780003__","flaeche":52104}}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::25832"}},"area":52109.374267578125}';
// Create Client Instance
var client = new netgis.Client( "container", config );
client.debug = true;
</script>
</body>
</html>

24
demo/proxy_raw.php Normal file
View File

@ -0,0 +1,24 @@
<?php
// URL
$query = $_SERVER[ "QUERY_STRING" ];
// Open Session
$session = curl_init( $query );
// Only return contents, no headers
curl_setopt( $session, CURLOPT_HEADER, false );
curl_setopt( $session, CURLOPT_RETURNTRANSFER, true );
// Execute
$response = curl_exec( $session );
// Output
header( "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept" );
header( "Access-Control-Allow-Origin: *" );
header( "Content-Type: application/json" );
echo $response;
// Done
curl_close( $session );

2
dist/netgis.min.css vendored

File diff suppressed because one or more lines are too long

688
dist/netgis.min.js vendored
View File

@ -1,253 +1,443 @@
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};
$jscomp.getGlobal=function(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Number.parseFloat",function(a){return a||parseFloat},"es6","es3");
$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,c,d){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==d||d>b)d=b;d=Number(d);0>d&&(d=Math.max(0,b+d));for(c=Number(c||0);c<d;c++)this[c]=a;return this}},"es6","es3");$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Number.parseFloat",function(a){return a||parseFloat},"es6","es3");$jscomp.polyfill("Number.parseInt",function(a){return a||parseInt},"es6","es3");
$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};
$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};
$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var e=c++;return{value:b(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};$jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a,c){return c})}},"es8","es3");
$jscomp.polyfill("Number.parseInt",function(a){return a||parseInt},"es6","es3");$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};$jscomp.assign="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");var netgis=netgis||{};
netgis.Attribution=function(){this.layers=this.client=null;this.items=[]};
netgis.Attribution.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-attribution netgis-text-primary";netgis.util.isDefined(this.client.config.map)&&netgis.util.isDefined(this.client.config.map.attribution)&&this.items.push(this.client.config.map.attribution);this.update();this.client.root.appendChild(this.root);this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.LAYER_SHOW,this.onLayerShow.bind(this));
this.client.on(netgis.Events.LAYER_HIDE,this.onLayerHide.bind(this))};netgis.Attribution.prototype.update=function(){this.root.innerHTML="&copy; "+this.items.join(", ")};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[b]=c.attribution)}};
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=netgis||{};
netgis.Client=function(a,b){this.build="20220826";this.debug=!1;netgis.util.isString(a)&&(a=document.getElementById(a));this.container=a;this.editable=!0;this.root=null;this.modules=[];this.callbacks={};this.config=this.createDefaultConfig();this.create();if(netgis.util.isDefined(b))if(netgis.util.isString(b)){var c=this;netgis.util.request(b,function(a){a=JSON.parse(a);netgis.util.merge(c.config,a);c.createModules();c.load();c.invoke(netgis.Events.CONTEXT_UPDATE,c.config);c.hideLoader()})}else netgis.util.merge(this.config,b),
this.createModules(),this.load(),this.invoke(netgis.Events.CONTEXT_UPDATE,this.config),this.hideLoader();else this.createModules(),this.load(),this.invoke(netgis.Events.CONTEXT_UPDATE,this.config),this.hideLoader()};
netgis.Client.prototype.createDefaultConfig=function(){return{map:{projection:"EPSG:3857",center:[1113194,6621293],minZoom:0,maxZoom:20,zoom:6,attribution:"NetGIS"},projections:[],layers:[{folder:0,type:netgis.LayerTypes.OSM,title:"Open Street Map",attribution:"OSM Contributors",active:!0}],folders:[{title:"Hintergrund",parent:-1}],styles:{editLayer:{fill:"rgba( 255, 0, 0, 0.5 )",stroke:"#ff0000",strokeWidth:3,pointRadius:6},select:{fill:"rgba( 0, 127, 255, 0.5 )",stroke:"#007fff",strokeWidth:3,pointRadius:6},
sketch:{fill:"rgba( 0, 127, 0, 0.5 )",stroke:"#007f00",strokeWidth:3,pointRadius:6},modify:{fill:"rgba( 0, 127, 0, 0.5 )",stroke:"#007f00",strokeWidth:3,pointRadius:6},parcel:{fill:"rgba( 127, 255, 255, 0.5 )",stroke:"#7fffff",strokeWidth:3}}}};
netgis.Client.prototype.create=function(){this.root=document.createElement("section");this.root.className="netgis-client";this.loader=document.createElement("div");this.loader.className="netgis-loader netgis-dialog netgis-text-primary";this.loader.innerHTML="<i class='fas fa-spinner'></i>";this.root.appendChild(this.loader);this.container.appendChild(this.root)};
netgis.Client.prototype.createModules=function(){this.editable=!0;this.container.hasAttribute("contenteditable")&&"false"===this.container.getAttribute("contenteditable")&&(this.editable=!1);this.container.hasAttribute("data-editable")&&(this.editable="true"===this.container.getAttribute("data-editable")?!0:!1);this.add(this.map=new netgis.MapOpenLayers);this.add(new netgis.Controls);this.add(new netgis.Attribution);this.add(new netgis.LayerTree);this.add(new netgis.Toolbar);this.add(new netgis.Menu);
this.add(new netgis.SearchPlace);this.add(new netgis.SearchParcel);this.add(new netgis.Modal)};
netgis.Client.prototype.load=function(){for(var a=0;a<this.modules.length;a++)this.modules[a].load();netgis.util.isDefined(this.config.output)?netgis.util.isDefined(this.config.output.id)&&(this.output=document.getElementById(this.config.output.id),this.output.value&&0<this.output.value.length&&(a=JSON.parse(this.output.value),this.invoke(netgis.Events.EDIT_FEATURES_LOADED,a))):(this.output=document.createElement("input"),this.output.setAttribute("type","hidden"),this.output.className="netgis-edit-output",
this.root.appendChild(this.output));this.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW);this.on(netgis.Events.EXPORT_BEGIN,this.onMapExportBegin.bind(this));this.on(netgis.Events.EXPORT_END,this.onMapExportEnd.bind(this));this.on(netgis.Events.EDIT_FEATURES_CHANGE,this.onEditFeaturesChange.bind(this))};netgis.Client.prototype.add=function(a){a.client=this;this.modules.push(a)};netgis.Client.prototype.on=function(a,b){netgis.util.isDefined(this.callbacks[a])||(this.callbacks[a]=[]);this.callbacks[a].push(b)};
netgis.Client.prototype.off=function(a,b){if(netgis.util.isDefined(this.callbacks[a]))if(netgis.util.isDefined(b)){for(var c=0;c<this.callbacks[a].length;c++)if(this.callbacks[a][c]===b){this.callbacks[a].splice(c,1);break}1>this.callbacks[a].length&&delete this.callbacks[a]}else delete this.callbacks[a]};netgis.Client.prototype.invoke=function(a,b){this.debug&&console.info("EVENT:",a,b);if(netgis.util.isDefined(this.callbacks[a]))for(var c=0;c<this.callbacks[a].length;c++)this.callbacks[a][c](b)};
netgis.Client.prototype.showLoader=function(){this.loader.classList.remove("netgis-hide")};netgis.Client.prototype.hideLoader=function(){this.loader.classList.add("netgis-hide")};netgis.Client.prototype.onHtmlResponse=function(a){this.root=netgis.util.create(a);this.container.appendChild(this.root)};netgis.Client.prototype.onEditFeaturesChange=function(a){a=JSON.stringify(a);this.output.value=a};netgis.Client.prototype.onMapExportBegin=function(a){this.showLoader()};
netgis.Client.prototype.onMapExportEnd=function(a){this.hideLoader()};netgis=netgis||{};netgis.Controls=function(){this.client=null};
netgis.Controls.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-controls";var a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="<i class='fas fa-search-plus'></i>";a.title="Hineinzoomen";a.addEventListener("click",this.onZoomIn.bind(this));this.root.appendChild(a);a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="<i class='fas fa-search-minus'></i>";a.title="Herauszoomen";a.addEventListener("click",
this.onZoomOut.bind(this));this.root.appendChild(a);this.client.root.appendChild(this.root)};netgis.Controls.prototype.onZoomIn=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,1)};netgis.Controls.prototype.onZoomOut=function(a){this.client.invoke(netgis.Events.MAP_CHANGE_ZOOM,-1)};netgis.Controls.prototype.onSettings=function(a){alert("TODO: settings dialog")};netgis=netgis||{};
netgis.Events=Object.freeze({CONTEXT_UPDATE:"CONTEXT_UPDATE",SET_MODE:"SET_MODE",LAYER_LIST_TOGGLE:"LAYER_LIST_TOGGLE",PANEL_TOGGLE:"PANEL_TOGGLE",PANEL_SHOW:"PANEL_SHOW",PANEL_HIDE:"PANEL_HIDE",LAYER_SHOW:"LAYER_SHOW",LAYER_HIDE:"LAYER_HIDE",LAYER_CREATED:"LAYER_CREATED",MAP_ZOOM_WKT:"MAP_ZOOM_WKT",MAP_SET_EXTENT:"MAP_SET_EXTENT",MAP_CHANGE_ZOOM:"MAP_CHANGE_ZOOM",MAP_UPDATE_STYLE:"MAP_UPDATE_STYLE",MAP_MODE_POINTS:"MAP_MODE_POINTS",MAP_MODE_LINES:"MAP_MODE_LINES",MAP_MODE_POLYGONS:"MAP_MODE_POLYGONS",EDIT_FEATURES_LOADED:"EDIT_FEATURES_LOADED",
EDIT_FEATURES_CHANGE:"EDIT_FEATURES_CHANGE",SEARCH_PLACE_REQUEST:"SEARCH_PLACE_REQUEST",SEARCH_PLACE_RESPONSE:"SEARCH_PLACE_RESPONSE",PARCEL_SHOW_PREVIEW:"PARCEL_SHOW_PREVIEW",PARCEL_HIDE_PREVIEW:"PARCEL_HIDE_PREVIEW",BUFFER_CHANGE:"BUFFER_CHANGE",BUFFER_ACCEPT:"BUFFER_ACCEPT",BUFFER_CANCEL:"BUFFER_CANCEL",DRAW_BUFFER_ON:"DRAW_BUFFER_ON",DRAW_BUFFER_OFF:"DRAW_BUFFER_OFF",DRAW_BUFFER_RADIUS_CHANGE:"DRAW_BUFFER_RADIUS_CHANGE",DRAW_BUFFER_SEGMENTS_CHANGE:"DRAW_BUFFER_SEGMENTS_CHANGE",SNAP_ON:"SNAP_ON",
SNAP_OFF:"SNAP_OFF",TRACING_ON:"TRACING_ON",TRACING_OFF:"TRACING_OFF",IMPORT_SHAPEFILE_SHOW:"IMPORT_SHAPEFILE_SHOW",IMPORT_GEOJSON_SHOW:"IMPORT_GEOJSON_SHOW",IMPORT_GML_SHOW:"IMPORT_GML_SHOW",IMPORT_SPATIALITE_SHOW:"IMPORT_SPATIALITE_SHOW",IMPORT_GEOPACKAGE_SHOW:"IMPORT_GEOPACKAGE_SHOW",IMPORT_SHAPEFILE:"IMPORT_SHAPEFILE",IMPORT_GEOJSON:"IMPORT_GEOJSON",IMPORT_GML:"IMPORT_GML",IMPORT_WKT:"IMPORT_WKT",IMPORT_SPATIALITE:"IMPORT_SPATIALITE",IMPORT_GEOPACKAGE:"IMPORT_GEOPACKAGE",EXPORT_PDF_SHOW:"EXPORT_PDF_SHOW",
EXPORT_JPEG_SHOW:"EXPORT_JPEG_SHOW",EXPORT_PNG_SHOW:"EXPORT_PNG_SHOW",EXPORT_GIF_SHOW:"EXPORT_GIF_SHOW",EXPORT_PDF:"EXPORT_PDF",EXPORT_JPEG:"EXPORT_JPEG",EXPORT_PNG:"EXPORT_PNG",EXPORT_GIF:"EXPORT_GIF",EXPORT_BEGIN:"EXPORT_BEGIN",EXPORT_END:"EXPORT_END",ADD_SERVICE_SHOW:"ADD_SERVICE_SHOW",ADD_SERVICE_WMS:"ADD_SERVICE_WMS",ADD_SERVICE_WFS:"ADD_SERVICE_WFS"});netgis=netgis||{};netgis.LayerTree=function(){this.folderDraw=this.folderImport=this.list=this.root=this.client=null};
netgis.LayerTree.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-layer-list netgis-dialog netgis-shadow netgis-hide";this.list=document.createElement("ul");this.list.className="root";this.root.appendChild(this.list);this.initDefaultFolders();this.tools=document.createElement("div");this.tools.className="netgis-layer-tools";this.tools.innerHTML="<hr/>";this.root.appendChild(this.tools);this.buttonAddService=document.createElement("button");this.buttonAddService.className=
"netgis-text-primary netgis-hover-primary";this.buttonAddService.innerHTML="<i class='fas fa-folder-plus'></i> Dienst hinzuf\u00fcgen";this.buttonAddService.addEventListener("click",this.onAddServiceClick.bind(this));this.tools.appendChild(this.buttonAddService);this.client.root.appendChild(this.root);this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.LAYER_LIST_TOGGLE,this.onLayerListToggle.bind(this));this.client.on(netgis.Events.LAYER_CREATED,
this.onLayerCreated.bind(this));this.client.on(netgis.Events.EDIT_FEATURES_CHANGE,this.onEditFeaturesChange.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WMS,this.onAddServiceWMS.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WFS,this.onAddServiceWFS.bind(this));this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this))};
netgis.LayerTree.prototype.initDefaultFolders=function(){this.folderDraw=this.createFolder("Zeichnung");this.folderDraw.classList.add("netgis-hide");this.list.appendChild(this.folderDraw);this.folderImport=this.createFolder("Importierte Ebenen");this.folderImport.classList.add("netgis-hide");this.list.appendChild(this.folderImport);this.folderServices=this.createFolder("Eigene Dienste");this.folderServices.classList.add("netgis-hide");this.list.appendChild(this.folderServices)};
netgis.LayerTree.prototype.clearAll=function(){this.list.innerHTML="";this.initDefaultFolders()};
netgis.LayerTree.prototype.createFolder=function(a){var b=document.createElement("li");b.className="netgis-folder netgis-hover-light";b.setAttribute("title",a);var c=document.createElement("label");c.className="netgis-icon";b.appendChild(c);var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",this.onFolderChange.bind(this));c.appendChild(d);c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-clip-text netgis-hover-text-primary";
c.innerHTML='<i class="fas fa-folder-open"></i>'+a;c.addEventListener("click",this.onFolderClick.bind(this));b.appendChild(c);a=document.createElement("ul");b.appendChild(a);return b};
netgis.LayerTree.prototype.createLayer=function(a,b,c){var d=document.createElement("li");d.setAttribute("title",b);d.className="netgis-folder-item netgis-hover-text-primary";var e=document.createElement("label");e.className="netgis-label netgis-clip-text";d.appendChild(e);var f=document.createElement("span");f.className="netgis-icon";e.appendChild(f);var g=document.createElement("input");g.setAttribute("type","checkbox");g.dataset.id=a;g.checked=c;g.addEventListener("change",this.onItemChange.bind(this));
f.appendChild(g);a=document.createElement("i");a.className="fas fa-th-large";e.appendChild(a);b=document.createTextNode(b);e.appendChild(b);b=document.createElement("span");e.appendChild(b);return d};netgis.LayerTree.prototype.addToFolder=function(a,b,c){a?(a=a.getElementsByTagName("ul")[0],a.appendChild(b)):a=this.list;c?a.insertBefore(b,a.firstChild):a.appendChild(b)};netgis.LayerTree.prototype.onFolderClick=function(a){a.currentTarget.parentElement.classList.toggle("netgis-active")};
netgis.LayerTree.prototype.onFolderChange=function(a){var b=a.currentTarget;a=b.checked;b=b.parentElement.parentElement;for(var c=b.getElementsByTagName("input"),d=1;d<c.length;d++){var e=c[d];e.checked=a;e=e.dataset.id;netgis.util.isDefined(e)&&(e=parseInt(e),this.client.invoke(a?netgis.Events.LAYER_SHOW:netgis.Events.LAYER_HIDE,{id:e}))}this.updateFolderChecks(b);a=b.parentElement.parentElement;-1!==a.className.search("netgis-folder")&&this.updateFolderChecks(a)};
netgis.LayerTree.prototype.updateFolderChecks=function(a){netgis.util.isDefined(a)||(a=this.list);for(var b=a.getElementsByClassName("netgis-folder-item"),c=0,d=0;d<b.length;d++){var e=b[d].getElementsByTagName("input")[0];e.checked&&c++}e=a.getElementsByTagName("input")[0];d=0;0<c&&(d=1);c===b.length&&(d=2);switch(d){case 0:e.checked=!1;e.classList.remove("netgis-partial");break;case 1:e.checked=!0;e.classList.add("netgis-partial");break;case 2:e.checked=!0,e.classList.remove("netgis-partial")}(a=
a.parentElement)&&a!==this.list&&(a=a.parentElement)&&-1!==a.className.search("netgis-folder")&&this.updateFolderChecks(a)};
netgis.LayerTree.prototype.onItemChange=function(a){var b=a.currentTarget;a=b.checked;var c=b.parentElement.parentElement.parentElement;b=parseInt(b.dataset.id);c=c.parentElement.parentElement;for(var d=c.getElementsByTagName("input"),e=0,f=1;f<d.length;f++)d[f].checked&&e++;-1!==c.className.search("netgis-folder")&&this.updateFolderChecks(c);this.client.invoke(a?netgis.Events.LAYER_SHOW:netgis.Events.LAYER_HIDE,{id:b})};netgis.LayerTree.prototype.onLayerListToggle=function(a){this.root.classList.toggle("netgis-hide")};
netgis.LayerTree.prototype.onContextUpdate=function(a){this.clearAll();var b=a.folders;a=a.layers;for(var c=[],d=0;d<b.length;d++){var e=b[d],f=this.createFolder(e.title);c.push(f)}for(d=0;d<a.length;d++)e=a[d],f=this.createLayer(d,e.title,e.active),this.addToFolder(c[e.folder],f);for(d=0;d<b.length;d++)e=b[d],f=c[d],-1===e.parent?this.list.appendChild(f):this.addToFolder(c[e.parent],f);for(d=0;d<a.length;d++)e=a[d],e.active&&this.client.invoke(netgis.Events.LAYER_SHOW,{id:d});for(d=0;d<c.length;d++)this.updateFolderChecks(c[d])};
netgis.LayerTree.prototype.onLayerCreated=function(a){var b=this.createLayer(a.id,a.title,a.checked);if("import"===a.folder){this.folderImport.classList.remove("netgis-hide");var c=this.folderImport}else"draw"===a.folder&&(this.folderDraw.classList.remove("netgis-hide"),c=this.folderDraw);this.addToFolder(c,b,!0);this.updateFolderChecks(c)};
netgis.LayerTree.prototype.onEditFeaturesChange=function(a){if(this.folderDraw){var b=this.folderDraw.getElementsByTagName("ul")[0],c=b.getElementsByTagName("input")[0],d=parseInt(c.dataset.id);c.checked||(c.checked=!0,this.updateFolderChecks(this.folderDraw),this.client.invoke(netgis.Events.LAYER_SHOW,{id:d}));b=b.getElementsByTagName("label")[0].getElementsByTagName("span");b[b.length-1].innerText=a.area&&0<a.area?" (Fl\u00e4che: "+netgis.util.formatArea(a.area,!0)+")":""}};
netgis.LayerTree.prototype.onAddServiceWMS=function(a){var b=this.createLayer(a.id,a.title,!0);this.folderServices.classList.remove("netgis-hide");this.addToFolder(this.folderServices,b,!0);this.updateFolderChecks(this.folderServices);this.client.invoke(netgis.Events.LAYER_SHOW,{id:a.id})};
netgis.LayerTree.prototype.onAddServiceWFS=function(a){var b=this.createLayer(a.id,a.title,!0);this.folderServices.classList.remove("netgis-hide");this.addToFolder(this.folderServices,b,!0);this.updateFolderChecks(this.folderServices);this.client.invoke(netgis.Events.LAYER_SHOW,{id:a.id})};netgis.LayerTree.prototype.onSetMode=function(a){a===netgis.Modes.SEARCH_PARCEL&&this.root.classList.add("netgis-hide")};
netgis.LayerTree.prototype.onAddServiceClick=function(a){this.client.invoke(netgis.Events.ADD_SERVICE_SHOW,null)};netgis=netgis||{};netgis.LayerTypes=Object.freeze({XYZ:"XYZ",OSM:"OSM",WMS:"WMS",WFS:"WFS",KML:"KML"});netgis=netgis||{};netgis.Map=function(){this.attribution=this.root=this.client=null};netgis.Map.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-map";this.client.root.appendChild(this.root)};netgis=netgis||{};netgis.MapOpenLayers=function(){netgis.Map.call(this);this.mode=null;this.toolbars={};this.map=this.view=null;this.layers=[];this.interactions={};this.sketch=this.selected=this.hover=this.parcelLayer=this.editLayer=this.snapFeatures=this.snap=null;this.editEventsSilent=!1;this.importLayerID=2E4;this.editLayerID=3E4;this.labelFont="4mm Verdana, sans-serif";this.drawBufferRadius=100;this.drawBufferSegments=3};netgis.MapOpenLayers.prototype=Object.create(netgis.Map.prototype);
netgis.MapOpenLayers.prototype.constructor=netgis.MapOpenLayers;
netgis.MapOpenLayers.prototype.load=function(){netgis.Map.prototype.load.call(this);this.dropTarget=document.createElement("div");this.dropTarget.className="netgis-drop-target netgis-hide";this.dropTarget.innerHTML="Datei hier ablegen!";this.root.appendChild(this.dropTarget);this.root.addEventListener("dragenter",this.onDragEnter.bind(this));this.root.addEventListener("dragover",this.onDragEnter.bind(this));this.root.addEventListener("dragend",this.onDragLeave.bind(this));this.root.addEventListener("dragleave",
this.onDragLeave.bind(this));this.root.addEventListener("drop",this.onDragDrop.bind(this));this.initMap();this.initDefaultLayers();this.initInteractions();this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.MAP_UPDATE_STYLE,this.onUpdateStyle.bind(this));this.client.on(netgis.Events.EDIT_FEATURES_LOADED,this.onEditFeaturesLoaded.bind(this));this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SNAP_ON,this.onSnapOn.bind(this));
this.client.on(netgis.Events.SNAP_OFF,this.onSnapOff.bind(this));this.client.on(netgis.Events.TRACING_ON,this.onTracingOn.bind(this));this.client.on(netgis.Events.TRACING_OFF,this.onTracingOff.bind(this));this.client.on(netgis.Events.LAYER_SHOW,this.onLayerShow.bind(this));this.client.on(netgis.Events.LAYER_HIDE,this.onLayerHide.bind(this));this.client.on(netgis.Events.MAP_ZOOM_WKT,this.onZoomWKT.bind(this));this.client.on(netgis.Events.MAP_SET_EXTENT,this.onSetExtent.bind(this));this.client.on(netgis.Events.MAP_CHANGE_ZOOM,
this.onChangeZoom.bind(this));this.client.on(netgis.Events.BUFFER_CHANGE,this.onBufferChange.bind(this));this.client.on(netgis.Events.BUFFER_ACCEPT,this.onBufferAccept.bind(this));this.client.on(netgis.Events.BUFFER_CANCEL,this.onBufferCancel.bind(this));this.client.on(netgis.Events.IMPORT_GEOJSON,this.onImportGeoJSON.bind(this));this.client.on(netgis.Events.IMPORT_GML,this.onImportGML.bind(this));this.client.on(netgis.Events.IMPORT_SHAPEFILE,this.onImportShapefile.bind(this));this.client.on(netgis.Events.IMPORT_WKT,
this.onImportWKT.bind(this));this.client.on(netgis.Events.IMPORT_SPATIALITE,this.onImportSpatialite.bind(this));this.client.on(netgis.Events.IMPORT_GEOPACKAGE,this.onImportGeopackage.bind(this));this.client.on(netgis.Events.EXPORT_PDF,this.onExportPDF.bind(this));this.client.on(netgis.Events.EXPORT_JPEG,this.onExportJPEG.bind(this));this.client.on(netgis.Events.EXPORT_PNG,this.onExportPNG.bind(this));this.client.on(netgis.Events.EXPORT_GIF,this.onExportGIF.bind(this));this.client.on(netgis.Events.PARCEL_SHOW_PREVIEW,
this.onParcelShowPreview.bind(this));this.client.on(netgis.Events.PARCEL_HIDE_PREVIEW,this.onParcelHidePreview.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WMS,this.onAddServiceWMS.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WFS,this.onAddServiceWFS.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_ON,this.onDrawBufferOn.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_OFF,this.onDrawBufferOff.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,this.onDrawBufferRadiusChange.bind(this));
this.client.on(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,this.onDrawBufferSegmentsChange.bind(this))};
netgis.MapOpenLayers.prototype.initMap=function(){var a=this.client.config;"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));this.view=new ol.View({projection:a.map.projection,center:a.map.center,minZoom:a.map.minZoom,maxZoom:a.map.maxZoom,zoom:a.map.zoom});this.map=new ol.Map({target:this.root,view:this.view,pixelRatio:1,moveTolerance:5,controls:[]});this.map.on("pointermove",this.onPointerMove.bind(this));
this.map.on("click",this.onSingleClick.bind(this));this.map.on("movestart",this.onMoveStart.bind(this));this.map.on("moveend",this.onMoveEnd.bind(this));this.view.on("change:resolution",this.onChangeResolution.bind(this))};
netgis.MapOpenLayers.prototype.initDefaultLayers=function(){this.editLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),style:this.styleEdit.bind(this),zIndex:this.editLayerID});this.map.addLayer(this.editLayer);this.previewLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),style:this.styleSketch.bind(this),zIndex:this.editLayerID+10});this.map.addLayer(this.previewLayer);this.parcelLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),style:this.styleParcel.bind(this),
zIndex:this.editLayerID+20});this.map.addLayer(this.parcelLayer);this.editEventsOn()};netgis.MapOpenLayers.prototype.editEventsOn=function(){this.editLayer.getSource().on("addfeature",this.onEditLayerAdd.bind(this));this.editLayer.getSource().on("removefeature",this.onEditLayerRemove.bind(this))};netgis.MapOpenLayers.prototype.editEventsOff=function(){};
netgis.MapOpenLayers.prototype.initInteractions=function(){this.interactions[netgis.Modes.VIEW]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.PANNING]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.ZOOMING_IN]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.ZOOMING_OUT]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.DRAW_POINTS]=[new ol.interaction.Draw({type:"Point",source:this.editLayer.getSource(),
style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_POINTS][0].on("drawend",this.onDrawPointsEnd.bind(this));this.interactions[netgis.Modes.DRAW_LINES]=[new ol.interaction.Draw({type:"LineString",source:this.editLayer.getSource(),style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_LINES][0].on("drawend",this.onDrawLinesEnd.bind(this));
this.interactions[netgis.Modes.DRAW_POLYGONS]=[new ol.interaction.Draw({type:"Polygon",source:this.editLayer.getSource(),style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURE_BEGIN]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURE_DRAW]=[new ol.interaction.Draw({type:"Polygon",style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];
this.interactions[netgis.Modes.CUT_FEATURE_DRAW][0].on("drawend",this.onCutFeatureDrawEnd.bind(this));this.interactions[netgis.Modes.MODIFY_FEATURES]=[new ol.interaction.Modify({source:this.editLayer.getSource(),deleteCondition:ol.events.condition.doubleClick,style:this.styleModify.bind(this)}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.MODIFY_FEATURES][0].on("modifyend",this.onModifyFeaturesEnd.bind(this));this.interactions[netgis.Modes.DELETE_FEATURES]=[new ol.interaction.DragPan,
new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.BUFFER_FEATURE_BEGIN]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.BUFFER_FEATURE_EDIT]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.snapFeatures=new ol.Collection;this.interactions[netgis.Modes.SEARCH_PLACE]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.SEARCH_PARCEL]=this.interactions[netgis.Modes.VIEW]};
netgis.MapOpenLayers.prototype.createLayer=function(a){var b=null;switch(a.type){case netgis.LayerTypes.XYZ:b=this.createLayerXYZ(a.url);break;case netgis.LayerTypes.OSM:b=this.createLayerOSM();break;case netgis.LayerTypes.WMS:b=this.createLayerWMS(a.url,a.name,a.format,a.username,a.password);break;case netgis.LayerTypes.WFS:b=this.createLayerWFS(a.url,a.name,this.client.config.map.projection,a.outputFormat)}b&&(a.minZoom&&b.setMinZoom(Number.parseFloat(a.minZoom)-1),a.maxZoom&&b.setMaxZoom(Number.parseFloat(a.maxZoom)));
return b};netgis.MapOpenLayers.prototype.createLayerXYZ=function(a){return new ol.layer.Tile({source:new ol.source.XYZ({url:a,crossOrigin:"anonymous"})})};netgis.MapOpenLayers.prototype.createLayerOSM=function(){return new ol.layer.Tile({source:new ol.source.XYZ({url:"https://{a-c}.tile.openstreetmap.de/{z}/{x}/{y}.png",crossOrigin:"anonymous"})})};
netgis.MapOpenLayers.prototype.createLayerWMS=function(a,b,c,d,e){a={url:a,params:{LAYERS:b,FORMAT:c?c:"image/png",TRANSPARENT:"true",VERSION:"1.1.1"},serverType:"mapserver",crossOrigin:"anonymous",hidpi:!1};d&&e&&(a.imageLoadFunction=function(a,b){var c=new XMLHttpRequest;c.open("GET",b);c.setRequestHeader("Authorization","Basic "+window.btoa(d+":"+e));c.onload=function(){a.getImage().src=b};c.send()});a=new ol.source.ImageWMS(a);return new ol.layer.Image({source:a,opacity:1})};
netgis.MapOpenLayers.prototype.createLayerWFS=function(a,b,c,d){a+="service=WFS&version=1.1.0&request=GetFeature";d=d?netgis.util.replace(d," ","+"):"application/json";var e=new ol.source.Vector({format:new ol.format.GeoJSON,strategy:ol.loadingstrategy.bbox,url:function(e){return a+"&typename="+b+"&srsname="+c+"&bbox="+e.join(",")+","+c+"&outputFormat="+d}}),f=new ol.layer.Vector({source:e}),g=this;e.on("featuresloadstart",function(a){g.removeSnapLayer(f)});e.on("featuresloadend",function(a){window.setTimeout(function(){g.addSnapLayer(f)},
10)});return f};netgis.MapOpenLayers.prototype.clearAll=function(){for(var a=0;a<this.layers.length;a++)this.map.removeLayer(this.layers[a]);this.layers=[];this.snapFeatures.clear()};netgis.MapOpenLayers.prototype.onUpdateStyle=function(a){a=new ol.style.Style({fill:new ol.style.Fill({color:a.polygon.fill}),stroke:new ol.style.Stroke({color:a.polygon.stroke,width:a.polygon.strokeWidth})});this.editLayer.setStyle(a)};
netgis.MapOpenLayers.prototype.styleEdit=function(a){var b=this.client.config.styles.editLayer.pointRadius;a=a.getGeometry();b=new ol.style.Style({image:new ol.style.Circle({radius:b,fill:new ol.style.Fill({color:this.client.config.styles.editLayer.stroke})}),fill:new ol.style.Fill({color:this.client.config.styles.editLayer.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.editLayer.stroke,width:this.client.config.styles.editLayer.strokeWidth})});a instanceof ol.geom.Polygon&&(a=
a.getArea(),b.setText(new ol.style.Text({text:[netgis.util.formatArea(a,!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.client.config.styles.editLayer.stroke}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]})));return b};
netgis.MapOpenLayers.prototype.styleSelect=function(a){var b=a.getGeometry();a=new ol.style.Style({image:new ol.style.Circle({radius:this.client.config.styles.select.pointRadius,fill:new ol.style.Fill({color:this.client.config.styles.select.stroke})}),fill:new ol.style.Fill({color:this.client.config.styles.select.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.select.stroke,width:this.client.config.styles.select.strokeWidth})});b instanceof ol.geom.Polygon&&(b=b.getArea(),a.setText(new ol.style.Text({text:[netgis.util.formatArea(b,
!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.client.config.styles.select.stroke}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]})));return a};
netgis.MapOpenLayers.prototype.styleModify=function(a){var b=new ol.style.Style({image:new ol.style.Circle({radius:this.client.config.styles.modify.pointRadius,fill:new ol.style.Fill({color:this.client.config.styles.modify.stroke})}),fill:new ol.style.Fill({color:this.client.config.styles.modify.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.modify.stroke,width:this.client.config.styles.modify.strokeWidth})});a=new ol.style.Style({image:new ol.style.Circle({radius:this.client.config.styles.modify.pointRadius,
fill:new ol.style.Fill({color:this.client.config.styles.modify.stroke})}),geometry:this.getGeometryPoints(a)});return[b,a]};
netgis.MapOpenLayers.prototype.styleSketch=function(a){var b=a.getGeometry(),c=new ol.style.Style({image:new ol.style.Circle({radius:this.client.config.styles.sketch.pointRadius,fill:new ol.style.Fill({color:this.client.config.styles.sketch.stroke})}),fill:new ol.style.Fill({color:this.client.config.styles.sketch.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.sketch.stroke,width:this.client.config.styles.sketch.strokeWidth})});b instanceof ol.geom.Polygon&&(b=b.getArea(),c.setText(new ol.style.Text({text:[netgis.util.formatArea(b,
!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.client.config.styles.sketch.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:this.client.config.styles.sketch.pointRadius,fill:new ol.style.Fill({color:this.client.config.styles.sketch.stroke})}),geometry:this.getGeometryPoints(a)});return[c,a]};
netgis.MapOpenLayers.prototype.styleParcel=function(){return new ol.style.Style({fill:new ol.style.Fill({color:this.client.config.styles.parcel.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.parcel.stroke,width:this.client.config.styles.parcel.strokeWidth})})};
netgis.MapOpenLayers.prototype.getGeometryPoints=function(a){var b=a.getGeometry();if(b instanceof ol.geom.LineString)return new ol.geom.MultiPoint(b.getCoordinates());if(b instanceof ol.geom.Polygon){a=[];b=b.getCoordinates();for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiPolygon){a=[];for(var f=b.getPolygons(),g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);
return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiLineString){a=[];f=b.getPolygons();for(g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}return b};netgis.MapOpenLayers.prototype.getActiveVectorLayers=function(){for(var a=[],b=this.map.getLayers().getArray(),c=this.layers,d=0;d<c.length;d++){var e=c[d];e instanceof ol.layer.Vector&&-1<b.indexOf(e)&&a.push(e)}return a};
netgis.MapOpenLayers.prototype.setMode=function(a){switch(this.mode){case netgis.Modes.BUFFER_FEATURE_EDIT:this.onBufferCancel(null);break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.onDrawBufferOff(null)}this.map.getInteractions().clear();var b=this.interactions[a];if(b)for(var c=0;c<b.length;c++)this.map.addInteraction(b[c]);this.snap&&(a===netgis.Modes.DRAW_POINTS||a===netgis.Modes.DRAW_LINES||a===netgis.Modes.DRAW_POLYGONS)&&this.map.addInteraction(this.snap);switch(a){default:this.editLayer.setStyle(this.styleEdit.bind(this));
break;case netgis.Modes.MODIFY_FEATURES:this.editLayer.setStyle(this.styleModify.bind(this))}this.mode&&this.root.classList.remove(this.getModeClassName(this.mode));a&&this.root.classList.add(this.getModeClassName(a));this.mode=a};netgis.MapOpenLayers.prototype.getModeClassName=function(a){a=a.toLowerCase();a=netgis.util.replace(a,"_","-");return"netgis-mode-"+a};
netgis.MapOpenLayers.prototype.setSnapOn=function(){this.snap=new ol.interaction.Snap({features:this.snapFeatures});this.map.addInteraction(this.snap);this.snapFeatures.changed()};netgis.MapOpenLayers.prototype.setSnapOff=function(){this.snap&&(this.map.removeInteraction(this.snap),this.snap=null)};
netgis.MapOpenLayers.prototype.setTracingOn=function(){var a=new ol.source.Vector({features:this.snapFeatures});this.tracing=new ol.interaction.Draw({type:"Polygon",source:this.editLayer.getSource(),style:this.styleSketch.bind(this),trace:!0,traceSource:a});a=this.interactions[netgis.Modes.DRAW_POLYGONS];a[0].setActive(!1);a.push(this.tracing);this.setMode(this.mode)};
netgis.MapOpenLayers.prototype.setTracingOff=function(){var a=this.interactions[netgis.Modes.DRAW_POLYGONS];a[0].setActive(!0);a.splice(a.indexOf(this.tracing),1);this.setMode(this.mode)};netgis.MapOpenLayers.prototype.addSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.push(a[b])};netgis.MapOpenLayers.prototype.removeSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.remove(a[b])};
netgis.MapOpenLayers.prototype.onSnapOn=function(a){this.setSnapOn()};netgis.MapOpenLayers.prototype.onSnapOff=function(a){this.setSnapOff()};netgis.MapOpenLayers.prototype.onTracingOn=function(a){this.setTracingOn()};netgis.MapOpenLayers.prototype.onTracingOff=function(a){this.setTracingOff()};netgis.MapOpenLayers.prototype.onLayerShow=function(a){if(a=this.layers[a.id])this.map.addLayer(a),a instanceof ol.layer.Vector&&this.addSnapLayer(a)};
netgis.MapOpenLayers.prototype.onLayerHide=function(a){if(a=this.layers[a.id])this.map.removeLayer(a),a instanceof ol.layer.Vector&&this.removeSnapLayer(a)};
netgis.MapOpenLayers.prototype.onContextUpdate=function(a){this.clearAll();var b=a.bbox;if(b){if(netgis.util.isDefined(this.client.config.map)&&netgis.util.isDefined(this.client.config.map.projection)){var c=ol.proj.fromLonLat([b[0],b[1]],this.client.config.map.projection);var d=ol.proj.fromLonLat([b[2],b[3]],this.client.config.map.projection)}else c=ol.proj.fromLonLat([b[0],b[1]]),d=ol.proj.fromLonLat([b[2],b[3]]);b[0]=c[0];b[1]=c[1];b[2]=d[0];b[3]=d[1];this.view.fit(b)}for(b=0;b<a.layers.length;b++)if(c=
this.createLayer(a.layers[b]))c.setZIndex(a.layers.length-b),this.layers[b]=c};netgis.MapOpenLayers.prototype.onAddServiceWMS=function(a){var b=this.createLayerWMS(a.url,a.name,a.format);b.setZIndex(a.id);this.layers[a.id]=b};netgis.MapOpenLayers.prototype.onAddServiceWFS=function(a){var b=this.createLayerWFS(a.url,a.name,this.client.config.map.projection,a.format);b.setZIndex(a.id);this.layers[a.id]=b};netgis.MapOpenLayers.prototype.onSetMode=function(a){this.setMode(a)};
netgis.MapOpenLayers.prototype.onSetExtent=function(a){var b=ol.proj.fromLonLat([a.minx,a.miny],this.client.config.map.projection);a=ol.proj.fromLonLat([a.maxx,a.maxy],this.client.config.map.projection);this.view.fit([b[0],b[1],a[0],a[1]])};netgis.MapOpenLayers.prototype.onChangeZoom=function(a){this.view.animate({zoom:this.view.getZoom()+a,duration:200})};netgis.MapOpenLayers.prototype.onZoomWKT=function(a){a=(new ol.format.WKT).readGeometry(a);this.view.fit(a,{duration:300,padding:[40,40,40,40]})};
netgis.MapOpenLayers.prototype.onPointerMove=function(a){a=a.pixel;var b=this.hover,c=this.styleSelect.bind(this);b&&(b.setStyle(this.styleEdit.bind(this)),b=null);var d=this;switch(this.mode){case netgis.Modes.DELETE_FEATURES:this.map.forEachFeatureAtPixel(a,function(a,f){f===d.editLayer&&(b=a,a.setStyle(c));return!0});break;case netgis.Modes.CUT_FEATURE_BEGIN:this.map.forEachFeatureAtPixel(a,function(a,f){f===d.editLayer&&(b=a,a.setStyle(c));return!0});break;case netgis.Modes.BUFFER_FEATURE_BEGIN:this.map.forEachFeatureAtPixel(a,
function(a,f){f===d.editLayer&&(b=a,a.setStyle(c));return!0});break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.updateDrawBufferPreview()}this.hover=b};
netgis.MapOpenLayers.prototype.onSingleClick=function(a){switch(this.mode){case netgis.Modes.DELETE_FEATURES:this.hover&&(this.editLayer.getSource().removeFeature(this.hover),this.hover=null);break;case netgis.Modes.CUT_FEATURE_BEGIN:this.hover&&(this.selected=this.hover,this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_DRAW));break;case netgis.Modes.BUFFER_FEATURE_BEGIN:this.hover&&(this.selected=this.hover,this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_EDIT))}};
netgis.MapOpenLayers.prototype.onMoveStart=function(a){};netgis.MapOpenLayers.prototype.onMoveEnd=function(a){};netgis.MapOpenLayers.prototype.onChangeResolution=function(a){};
netgis.MapOpenLayers.prototype.onCutFeatureDrawEnd=function(a){var b=a.feature;if(a=this.selected){var c=new jsts.io.OL3Parser,d=c.read(a.getGeometry());b=c.read(b.getGeometry());d=d.difference(b);c=c.write(d);c=new ol.Feature({geometry:c});d=this.editLayer.getSource();d.removeFeature(a);d.addFeature(c);this.selected=c}this.editEventsSilent=!0;this.splitMultiPolygons(this.editLayer);this.editEventsSilent=!1;this.updateEditOutput()};
netgis.MapOpenLayers.prototype.onModifyFeaturesEnd=function(a){this.updateEditOutput();this.updateEditArea()};netgis.MapOpenLayers.prototype.createBufferFeature=function(a,b,c){a=this.createBufferGeometry(a,b,c);return new ol.Feature({geometry:a})};netgis.MapOpenLayers.prototype.createBufferGeometry=function(a,b,c){var d=new jsts.io.OL3Parser;a=d.read(a).buffer(b,c);return d.write(a)};
netgis.MapOpenLayers.prototype.onBufferChange=function(a){var b=this.editLayer.getSource(),c=this.selected;this.sketch&&b.removeFeature(this.sketch);c&&(a=this.createBufferFeature(c.getGeometry(),a.radius,a.segments),b.addFeature(a),this.sketch=a)};netgis.MapOpenLayers.prototype.onBufferAccept=function(a){this.selected&&this.sketch&&this.editLayer.getSource().removeFeature(this.selected);this.selected=this.sketch=null};
netgis.MapOpenLayers.prototype.onBufferCancel=function(a){this.sketch&&(this.editLayer.getSource().removeFeature(this.sketch),this.sketch=null);this.selected=null};netgis.MapOpenLayers.prototype.onDrawPointsEnd=function(a){(a=this.previewLayer.getSource().getFeatures()[0])&&this.editLayer.getSource().addFeature(a.clone())};netgis.MapOpenLayers.prototype.onDrawLinesEnd=function(a){(a=this.previewLayer.getSource().getFeatures()[0])&&this.editLayer.getSource().addFeature(a.clone())};
netgis.MapOpenLayers.prototype.onDrawBufferOn=function(a){a=this.createBufferFeature(new ol.geom.Point(this.client.config.map.center),this.drawBufferRadius,this.drawBufferSegments);this.previewLayer.getSource().addFeature(a)};netgis.MapOpenLayers.prototype.onDrawBufferOff=function(a){this.previewLayer.getSource().clear()};netgis.MapOpenLayers.prototype.onDrawBufferRadiusChange=function(a){this.drawBufferRadius=a;this.updateDrawBufferPreview()};
netgis.MapOpenLayers.prototype.onDrawBufferSegmentsChange=function(a){this.drawBufferSegments=a;this.updateDrawBufferPreview()};netgis.MapOpenLayers.prototype.updateDrawBufferPreview=function(){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.MapOpenLayers.prototype.onEditLayerAdd=function(a){this.updateEditLayerItem();this.updateEditOutput();this.snapFeatures.push(a.feature)};netgis.MapOpenLayers.prototype.onEditLayerRemove=function(a){this.updateEditOutput();this.snapFeatures.remove(a.feature)};netgis.MapOpenLayers.prototype.onEditLayerChange=function(a){this.updateEditOutput()};
netgis.MapOpenLayers.prototype.updateEditOutput=function(){var a=this.editLayer.getSource().getFeatures(),b=this.client.config.map.projection,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;this.editEventsSilent||this.client.invoke(netgis.Events.EDIT_FEATURES_CHANGE,c)};
netgis.MapOpenLayers.prototype.updateEditLayerItem=function(){var a=this.editLayerID;this.layers[a]||(this.layers[a]=this.editLayer,this.client.invoke(netgis.Events.LAYER_CREATED,{id:a,title:"Zeichnung",checked:!0,folder:"draw"}))};netgis.MapOpenLayers.prototype.updateEditArea=function(){};netgis.MapOpenLayers.prototype.onEditFeaturesLoaded=function(a){var b=this;window.setTimeout(function(){b.createLayerGeoJSON("Import",a)},10)};
netgis.MapOpenLayers.prototype.onDragEnter=function(a){a.preventDefault();this.dropTarget.classList.remove("netgis-hide");return!1};netgis.MapOpenLayers.prototype.onDragLeave=function(a){this.dropTarget.classList.add("netgis-hide");return!1};
netgis.MapOpenLayers.prototype.onDragDrop=function(a){console.info("Drag Drop");this.dropTarget.classList.add("netgis-hide");a.preventDefault();a=a.dataTransfer.files[0];var b=new FileReader;b.onload=this.onDragLoad.bind(this);console.log("File:",a);b.readAsArrayBuffer(a);return!1};netgis.MapOpenLayers.prototype.onDragLoad=function(a){console.log("On Load:",a.target);this.loadShape(a.target.result)};netgis.MapOpenLayers.prototype.loadShape=function(a){var b=this;shp(a).then(function(a){b.onShapeLoad(a)})};
netgis.MapOpenLayers.prototype.onShapeLoad=function(a){console.info("Shapefile To Geojson:",a);a=(new ol.format.GeoJSON({dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})).readFeatures(a);this.importLayer.getSource().addFeatures(a);this.view.fit(this.importLayer.getSource().getExtent(),{})};netgis.MapOpenLayers.prototype.onImportGeoJSON=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGeoJSON(b,a.target.result)};d.readAsText(a)};
netgis.MapOpenLayers.prototype.onImportGML=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGML(b,a.target.result)};d.readAsText(a)};netgis.MapOpenLayers.prototype.onImportShapefile=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerShapefile(b,a.target.result)};d.readAsArrayBuffer(a)};
netgis.MapOpenLayers.prototype.onImportSpatialite=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerSpatialite(b,a.target.result)};d.readAsArrayBuffer(a)};netgis.MapOpenLayers.prototype.onImportGeopackage=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGeopackage(b,a.target.result)};d.readAsArrayBuffer(a)};
netgis.MapOpenLayers.prototype.createLayerGeoJSON=function(a,b){var c=new ol.format.GeoJSON;a=c.readProjection(b);b=c.readFeatures(b,{featureProjection:this.client.config.map.projection});a=a.getCode();switch(a){case "EPSG:3857":case "EPSG:4326":case this.client.config.map.projection:break;default:console.warn("Unsupported Import Projection:",a)}this.addImportedFeatures(b)};
netgis.MapOpenLayers.prototype.createLayerGML=function(a,b){console.warn("GML support is experimental!");a=[];b=(new DOMParser).parseFromString(b,"text/xml").getElementsByTagName("gml:featureMember");for(var c=0;c<b.length;c++){for(var d={},e=b[c].children[0],f=0;f<e.attributes.length;f++){var g=e.attributes[f];d[g.nodeName]=g.nodeValue}for(f=0;f<e.children.length;f++)if(g=e.children[f],"ogr:geometryProperty"!==g.nodeName){var h=g.nodeName.split(":");d[h[h.length-1]]=g.innerHTML}e=e.getElementsByTagName("ogr:geometryProperty")[0].children[0];
(f=e.getAttribute("srsName"))&&"EPSG:4326"!==f&&f!==this.client.config.map.projection&&console.warn("Unsupported Import Projection:",f);switch(e.nodeName){case "gml:Polygon":d.geometry=this.gmlParsePolygon(e,f);break;case "gml:MultiPolygon":d.geometry=this.gmlParseMultiPolygon(e,f)}d=new ol.Feature(d);a.push(d)}this.addImportedFeatures(a)};
netgis.MapOpenLayers.prototype.gmlParsePolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:LinearRing");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:coordinates")[0].innerHTML;c.push(this.gmlParseCoordinates(e,b))}return new ol.geom.Polygon(c)};
netgis.MapOpenLayers.prototype.gmlParseMultiPolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:polygonMember");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:Polygon")[0];c.push(this.gmlParsePolygon(e,b))}return new ol.geom.MultiPolygon(c)};netgis.MapOpenLayers.prototype.gmlParseCoordinates=function(a,b){a=a.split(" ");for(var c=0;c<a.length;c++){a[c]=a[c].split(",");for(var d=0;d<a[c].length;d++)a[c][d]=Number.parseFloat(a[c][d]);b&&(a[c]=ol.proj.transform(a[c],b,this.client.config.map.projection))}return a};
netgis.MapOpenLayers.prototype.createLayerShapefile=function(a,b){var c=this;shp(b).then(function(a){var b=new ol.format.GeoJSON;b.readProjection(a);a=b.readFeatures(a,{featureProjection:c.client.config.map.projection});c.addImportedFeatures(a)})};
netgis.MapOpenLayers.prototype.createLayerSpatialite=function(a,b){var c=this;window.initSqlJs().then(function(a){var d=[],f=new Uint8Array(b);a=new a.Database(f);var g=a.exec("SELECT name FROM sqlite_schema WHERE type = 'table' \n\t\t\t\t\tAND name NOT LIKE 'sqlite_%' \n\t\t\t\t\tAND name NOT LIKE 'sql_%' \n\t\t\t\t\tAND name NOT LIKE 'idx_%' \n\t\t\t\t\tAND name NOT LIKE 'spatial_ref_sys%' \n\t\t\t\t\tAND name NOT LIKE 'spatialite_%' \n\t\t\t\t\tAND name NOT LIKE 'geometry_columns%' \n\t\t\t\t\tAND name NOT LIKE 'views_%' \n\t\t\t\t\tAND name NOT LIKE 'virts_%' \n\t\t\t\t\tAND name NOT LIKE 'SpatialIndex' \n\t\t\t\t\tAND name NOT LIKE 'ElementaryGeometries' \n\t\t\t\t;");f=
g[0].values;for(var h=0;h<f.length;h++){g=a.exec("SELECT * FROM "+f[h][0]);var k=g[0];g=null;for(var l=0;l<k.columns.length;l++){if("geometry"===k.columns[l].toLowerCase()){g=l;break}if("geom"===k.columns[l].toLowerCase()){g=l;break}}k=k.values;for(l=0;l<k.length;l++){var m=k[l][g],n=new Uint8Array(m.length-43-1+5);n[0]=m[1];n[1]=m[39];n[2]=m[40];n[3]=m[41];n[4]=m[42];for(var p=m.length-43-1,q=0;q<p;q++)n[5+q]=m[43+q];m=(new ol.format.WKB).readGeometry(n,{featureProjection:c.client.config.map.projection});
d.push(new ol.Feature({geometry:m}))}}c.addImportedFeatures(d)})};
netgis.MapOpenLayers.prototype.createLayerGeopackage=function(a,b){var c=this;a=new Uint8Array(b);window.GeoPackage.setSqljsWasmLocateFile(function(a){return c.client.config.import.geopackageLibURL+a});window.GeoPackage.GeoPackageAPI.open(a).then(function(a){for(var b=[],d=new ol.format.GeoJSON,g=a.getFeatureTables(),h=0;h<g.length;h++)for(var k=a.queryForGeoJSONFeaturesInTable(g[h]),l=0;l<k.length;l++){var m=d.readGeometry(k[l].geometry,{featureProjection:c.client.config.map.projection});m=new ol.Feature({geometry:m});
b.push(m)}c.addImportedFeatures(b)})};netgis.MapOpenLayers.prototype.addImportedFeatures=function(a){this.editEventsSilent=!0;this.editLayer.getSource().addFeatures(a);this.editEventsSilent=!1;this.updateEditOutput();if(0<a.length){for(var b=a[0].getGeometry().getExtent(),c=1;c<a.length;c++)ol.extent.extend(b,a[c].getGeometry().getExtent());this.view.fit(b,{duration:300,padding:[40,40,40,40]})}};
netgis.MapOpenLayers.prototype.onImportWKT=function(a){a=(new ol.format.WKT).readGeometry(a);a=new ol.Feature({geometry:a});this.addImportedFeatures([a])};netgis.MapOpenLayers.prototype.onExportPDF=function(a){this.exportImage("pdf",a.resx,a.resy,a.mode,a.margin)};netgis.MapOpenLayers.prototype.onExportJPEG=function(a){this.exportImage("jpeg",a.resx,a.resy)};netgis.MapOpenLayers.prototype.onExportPNG=function(a){this.exportImage("png",a.resx,a.resy)};
netgis.MapOpenLayers.prototype.onExportGIF=function(a){this.exportImage("gif",a.resx,a.resy)};netgis.MapOpenLayers.prototype.onParcelShowPreview=function(a){a=(new ol.format.WKT).readGeometry(a.geom);a=new ol.Feature({geometry:a});this.parcelLayer.getSource().clear();this.parcelLayer.getSource().addFeature(a)};netgis.MapOpenLayers.prototype.onParcelHidePreview=function(a){this.parcelLayer.getSource().clear()};netgis.MapOpenLayers.prototype.getWidth=function(){return this.map.getSize()[0]};
netgis.MapOpenLayers.prototype.getHeight=function(){return this.map.getSize()[1]};
netgis.MapOpenLayers.prototype.exportImage=function(a,b,c,d,e){this.client.invoke(netgis.Events.EXPORT_BEGIN,null);var f=this,g=this.root,h=this.map,k=this.client.config,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 p=n.getContext("2d");p.webkitImageSmoothingEnabled=!1;p.mozImageSmoothingEnabled=!1;p.imageSmoothingEnabled=!1;Array.prototype.forEach.call(document.querySelectorAll(".ol-layer canvas"),function(a){if(0<a.width){var b=a.parentNode.style.opacity;p.globalAlpha=""===b?1:Number(b);b=a.style.transform.match(/^matrix\(([^\(]*)\)$/)[1].split(",").map(Number);CanvasRenderingContext2D.prototype.setTransform.apply(p,b);p.drawImage(a,0,0)}});p.drawImage(l,
0,0);p.fillStyle="#fff";p.fillRect(0,n.height-30,140,30);p.fillStyle="#000";p.font="4mm sans-serif";p.fillText(netgis.util.getTimeStamp(),10,n.height-10);var q=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.export.defaultFilename+".pdf"});window.open(n,"_blank");break;case "jpeg":window.navigator.msSaveBlob?window.navigator.msSaveBlob(n.msToBlob(),k.export.defaultFilename+".jpg"):(q.setAttribute("download",k.export.defaultFilename+".jpg"),q.setAttribute("href",n.toDataURL("image/jpeg",1)),q.click());break;case "png":window.navigator.msSaveBlob?
window.navigator.msSaveBlob(n.msToBlob(),k.export.defaultFilename+".png"):(q.setAttribute("download",k.export.defaultFilename+".png"),q.setAttribute("href",n.toDataURL("image/png",1)),q.click());break;case "gif":q.setAttribute("download",k.export.defaultFilename+".gif"),v=new GIF({workerScript:k.export.gifWebWorker,quality:1}),v.addFrame(n),v.on("finished",function(a){q.setAttribute("href",window.URL.createObjectURL(a));q.click()}),v.render()}h.setTarget(g);g.removeChild(m);f.client.invoke(netgis.Events.EXPORT_END,
null)});h.renderSync()};l.src=k.export.logo};netgis.MapOpenLayers.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=netgis||{};netgis.Menu=function(){this.root=this.client=null;this.sections=[]};
netgis.Menu.prototype.load=function(){this.root=document.createElement("header");this.root.className="netgis-menu netgis-primary netgis-shadow";var a=document.createElement("div");this.root.appendChild(a);var b=this.createButton('Ebenen<i class="fab fa-buffer"></i>',!0);b.addEventListener("click",this.onToggleClick.bind(this));a.appendChild(b);b=this.createButton('Suche<i class="fas fa-search" style="position: relative; top: 0.3mm;"></i>',!0);b.addEventListener("click",this.onSearchPlaceClick.bind(this));
a.appendChild(b);b=this.createButton('Flurst\u00fccke<i class="fas fa-vector-square" style="position: relative; top: 0.3mm;"></i>',!0);b.addEventListener("click",this.onSearchParcelClick.bind(this));a.appendChild(b);if(this.client.editable){b=this.createMenu('<i class="fas fa-caret-down"></i>Zeichnen');var c=b.getElementsByTagName("ul")[0];a.appendChild(b);c.appendChild(this.createMenuItem('<i class="fas fa-map-marker-alt"></i>Punkte',this.onDrawPointClick.bind(this)));c.appendChild(this.createMenuItem('<i class="fas fa-minus"></i>Linien',
this.onDrawLineClick.bind(this)));c.appendChild(this.createMenuItem('<i class="fas fa-vector-square"></i>Polygone',this.onDrawPolygonClick.bind(this)));b=this.createMenu('<i class="fas fa-caret-down"></i>Bearbeiten');c=b.getElementsByTagName("ul")[0];a.appendChild(b);c.appendChild(this.createMenuItem('<i class="fas fa-cut"></i>Ausschneiden',this.onCutFeatureClick.bind(this)));c.appendChild(this.createMenuItem('<i class="fas fa-arrows-alt"></i>Verschieben',this.onModifyFeaturesClick.bind(this)));c.appendChild(this.createMenuItem('<i class="fas fa-eraser"></i>L\u00f6schen',
this.onDeleteFeaturesClick.bind(this)));c.appendChild(this.createMenuItem('<i class="far fa-dot-circle"></i>Puffern',this.onBufferFeatureClick.bind(this)));b=this.createMenu('<i class="fas fa-caret-down"></i>Import');a.appendChild(b);b=b.getElementsByTagName("ul")[0];b.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GeoJSON',this.onImportGeoJSONClick.bind(this)));b.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GML',this.onImportGMLClick.bind(this)));b.appendChild(this.createMenuItem('<i class="fas fa-file"></i>Shapefile',
this.onImportShapefileClick.bind(this)));b.appendChild(this.createMenuItem('<i class="fas fa-file"></i>Spatialite',this.onImportSpatialiteClick.bind(this)));b.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GeoPackage',this.onImportGeopackageClick.bind(this)));b=this.createMenu('<i class="fas fa-caret-down"></i>Export');a.appendChild(b);a=b.getElementsByTagName("ul")[0];a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>PDF',this.onExportPDFClick.bind(this)));a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>JPEG',
this.onExportJPEGClick.bind(this)));a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>PNG',this.onExportPNGClick.bind(this)));a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GIF',this.onExportGIFClick.bind(this)))}this.client.root.appendChild(this.root)};netgis.Menu.prototype.createButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-primary netgis-hover-primary";b&&(c.className+=" netgis-right");c.innerHTML=a;return c};
netgis.Menu.prototype.createMenu=function(a){var b=document.createElement("div");b.className="netgis-dropdown";var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-primary netgis-hover-primary";c.innerHTML=a;b.appendChild(c);a=document.createElement("ul");a.className="netgis-dropdown-content netgis-dialog netgis-shadow";b.appendChild(a);return b};
netgis.Menu.prototype.createMenuItem=function(a,b){var c=document.createElement("li");c.className="netgis-hover-light";var d=document.createElement("button");d.setAttribute("type","button");d.innerHTML=a;d.addEventListener("click",b);c.appendChild(d);return c};netgis.Menu.prototype.onToggleClick=function(a){this.client.invoke(netgis.Events.LAYER_LIST_TOGGLE,null)};netgis.Menu.prototype.onDrawPointClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POINTS)};
netgis.Menu.prototype.onDrawLineClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_LINES)};netgis.Menu.prototype.onDrawPolygonClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POLYGONS)};netgis.Menu.prototype.onCutFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_BEGIN)};netgis.Menu.prototype.onModifyFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.MODIFY_FEATURES)};
netgis.Menu.prototype.onDeleteFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DELETE_FEATURES)};netgis.Menu.prototype.onBufferFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_BEGIN)};netgis.Menu.prototype.onSearchPlaceClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.SEARCH_PLACE)};netgis.Menu.prototype.onSearchParcelClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.SEARCH_PARCEL)};
netgis.Menu.prototype.onSearchDataClick=function(a){alert("TODO: data search interface")};netgis.Menu.prototype.onImportOWSClick=function(a){alert("TODO: ows import interface, try setting url parameter '?ows=<url>'")};netgis.Menu.prototype.onImportShapefileClick=function(a){this.client.invoke(netgis.Events.IMPORT_SHAPEFILE_SHOW,null)};netgis.Menu.prototype.onImportGeoJSONClick=function(a){this.client.invoke(netgis.Events.IMPORT_GEOJSON_SHOW,null)};netgis.Menu.prototype.onImportKMLClick=function(a){alert("TODO: kml import interface")};
netgis.Menu.prototype.onImportGMLClick=function(a){this.client.invoke(netgis.Events.IMPORT_GML_SHOW,null)};netgis.Menu.prototype.onImportSpatialiteClick=function(a){this.client.invoke(netgis.Events.IMPORT_SPATIALITE_SHOW,null)};netgis.Menu.prototype.onImportGeopackageClick=function(a){this.client.invoke(netgis.Events.IMPORT_GEOPACKAGE_SHOW,null)};netgis.Menu.prototype.onExportPDFClick=function(a){this.client.invoke(netgis.Events.EXPORT_PDF_SHOW,null)};
netgis.Menu.prototype.onExportJPEGClick=function(a){this.client.invoke(netgis.Events.EXPORT_JPEG_SHOW,null)};netgis.Menu.prototype.onExportPNGClick=function(a){this.client.invoke(netgis.Events.EXPORT_PNG_SHOW,null)};netgis.Menu.prototype.onExportGIFClick=function(a){this.client.invoke(netgis.Events.EXPORT_GIF_SHOW,null)};netgis=netgis||{};netgis.Modal=function(){this.addService=this.exportGIF=this.exportPNG=this.exportJPEG=this.exportPDF=this.importShapefile=this.importGML=this.importGeoJSON=this.client=null;this.addServiceID=1E4};
netgis.Modal.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-modal";this.root.addEventListener("click",this.onRootClick.bind(this));this.importGeoJSON=this.createImportGeoJSON();this.root.appendChild(this.importGeoJSON);this.importGML=this.createImportGML();this.root.appendChild(this.importGML);this.importShapefile=this.createImportShapefile();this.root.appendChild(this.importShapefile);this.importSpatialite=this.createImportSpatialite();this.root.appendChild(this.importSpatialite);
this.importGeopackage=this.createImportGeopackage();this.root.appendChild(this.importGeopackage);this.exportPDF=this.createExportPDF();this.root.appendChild(this.exportPDF);this.exportJPEG=this.createExportJPEG();this.root.appendChild(this.exportJPEG);this.exportPNG=this.createExportPNG();this.root.appendChild(this.exportPNG);this.exportGIF=this.createExportGIF();this.root.appendChild(this.exportGIF);this.addService=this.createAddService();this.root.appendChild(this.addService);this.client.root.appendChild(this.root);
this.client.on(netgis.Events.IMPORT_GEOJSON_SHOW,this.onImportGeoJSONShow.bind(this));this.client.on(netgis.Events.IMPORT_GML_SHOW,this.onImportGMLShow.bind(this));this.client.on(netgis.Events.IMPORT_SHAPEFILE_SHOW,this.onImportShapefileShow.bind(this));this.client.on(netgis.Events.IMPORT_SPATIALITE_SHOW,this.onImportSpatialiteShow.bind(this));this.client.on(netgis.Events.IMPORT_GEOPACKAGE_SHOW,this.onImportGeopackageShow.bind(this));this.client.on(netgis.Events.EXPORT_PDF_SHOW,this.onExportPDFShow.bind(this));
this.client.on(netgis.Events.EXPORT_JPEG_SHOW,this.onExportJPEGShow.bind(this));this.client.on(netgis.Events.EXPORT_PNG_SHOW,this.onExportPNGShow.bind(this));this.client.on(netgis.Events.EXPORT_GIF_SHOW,this.onExportGIFShow.bind(this));this.client.on(netgis.Events.ADD_SERVICE_SHOW,this.onAddServiceShow.bind(this))};
netgis.Modal.prototype.createImportGeoJSON=function(){var a=this.createContainer("Import GeoJSON");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","<ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:",".geojson,.json",this.onImportGeoJSONChange.bind(this));this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Importieren",this.onImportGeoJSONAccept.bind(this));return a};
netgis.Modal.prototype.createImportGML=function(){var a=this.createContainer("Import GML");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","<ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:",".gml,.xml",this.onImportGMLChange.bind(this));this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Importieren",this.onImportGMLAccept.bind(this));return a};
netgis.Modal.prototype.createImportShapefile=function(){var a=this.createContainer("Import Shapefile");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","<ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:","application/zip",this.onImportShapefileChange.bind(this));this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Importieren",this.onImportShapefileAccept.bind(this));
return a};
netgis.Modal.prototype.createImportSpatialite=function(){var a=this.createContainer("Import Spatialite");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","<ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:",".sqlite",this.onImportSpatialiteChange.bind(this));this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Importieren",this.onImportSpatialiteAccept.bind(this));return a};
netgis.Modal.prototype.createImportGeopackage=function(){var a=this.createContainer("Import GeoPackage");this.createText(a,"Unterst\u00fctzte Koordinatensysteme:","<ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>");this.createInputFile(a,"Datei ausw\u00e4hlen / ablegen:",".gpkg",this.onImportGeopackageChange.bind(this));this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Importieren",this.onImportGeopackageAccept.bind(this));return a};
netgis.Modal.prototype.createExportPDF=function(){var a=this.createContainer("Export PDF");this.createInputInteger(a,"Breite (Pixel):",800,0,4096);this.createInputInteger(a,"H\u00f6he (Pixel):",600,0,4096);this.createInputInteger(a,"Seitenr\u00e4nder (Millimeter):",10,0,100);this.createInputCheckbox(a,"Querformat:",!0);this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Exportieren",this.onExportPDFAccept.bind(this));return a};
netgis.Modal.prototype.createExportJPEG=function(){var a=this.createContainer("Export JPEG");this.createInputInteger(a,"Breite (Pixel):",800,0,4096);this.createInputInteger(a,"H\u00f6he (Pixel):",600,0,4096);this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Exportieren",this.onExportJPEGAccept.bind(this));return a};
netgis.Modal.prototype.createExportPNG=function(){var a=this.createContainer("Export PNG");this.createInputInteger(a,"Breite (Pixel):",800,0,4096);this.createInputInteger(a,"H\u00f6he (Pixel):",600,0,4096);this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Exportieren",this.onExportPNGAccept.bind(this));return a};
netgis.Modal.prototype.createExportGIF=function(){var a=this.createContainer("Export GIF");this.createInputInteger(a,"Breite (Pixel):",800,0,4096);this.createInputInteger(a,"H\u00f6he (Pixel):",600,0,4096);this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Exportieren",this.onExportGIFAccept.bind(this));return a};
netgis.Modal.prototype.createAddService=function(){var a=this.createContainer("Dienst hinzuf\u00fcgen");this.createInputText(a,"WMS/WFS URL:");this.createSpace(a);this.createButton(a,"<i class='fas fa-cloud-download-alt'></i>Dienst laden",this.onAddServiceLoad.bind(this));this.createSpace(a);this.createInputHidden(a);this.createText(a,"Bezeichnung:","");this.createInputSelect(a,"Kartenebene:",[]);this.createInputSelect(a,"Format:",[]);this.createSpace(a);this.createButton(a,"<i class='fas fa-check'></i>Dienst hinzuf\u00fcgen",
this.onAddServiceAccept.bind(this));return a};netgis.Modal.prototype.show=function(a){this.root.classList.add("netgis-show");for(var b=this.root.getElementsByClassName("netgis-dialog"),c=0;c<b.length;c++)b[c].classList.remove("netgis-show");a.classList.add("netgis-show")};netgis.Modal.prototype.hide=function(){this.root.classList.remove("netgis-show")};
netgis.Modal.prototype.createContainer=function(a){var b=document.createElement("section");b.className="netgis-dialog netgis-shadow";var c=document.createElement("header"),d=document.createElement("button");d.setAttribute("type","button");d.className="netgis-primary netgis-hover-primary";d.innerHTML="<h3>"+a+"</h3>";d.addEventListener("click",this.onHeaderClick.bind(this));c.appendChild(d);a=document.createElement("span");a.innerHTML="<i class='fas fa-times'></i>";d.appendChild(a);b.appendChild(c);
c=document.createElement("div");c.className="netgis-modal-content";b.appendChild(c);d=document.createElement("table");c.appendChild(d);return b};netgis.Modal.prototype.createSpace=function(a){var b=document.createElement("tr");b.className="netgis-space";var c=document.createElement("td");c.setAttribute("colspan",100);b.appendChild(c);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(b);return c};
netgis.Modal.prototype.createButton=function(a,b,c){var d=document.createElement("tr"),e=document.createElement("td");e.setAttribute("colspan",100);d.appendChild(e);var f=document.createElement("button");f.setAttribute("type","button");f.className="netgis-primary netgis-hover-primary";f.innerHTML=b;c&&f.addEventListener("click",c);e.appendChild(f);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(d);return f};
netgis.Modal.prototype.createInputHidden=function(a){var b=document.createElement("tr");b.className="netgis-hidden";var c=document.createElement("td");b.appendChild(c);var d=document.createElement("input");d.setAttribute("type","hidden");c.appendChild(d);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(b);return d};
netgis.Modal.prototype.createInputText=function(a,b){var c=document.createElement("tr"),d=document.createElement("th");d.className="netgis-padding";var e=document.createElement("label");e.innerHTML=b;d.appendChild(e);c.appendChild(d);b=document.createElement("td");b.className="netgis-padding";c.appendChild(b);d=document.createElement("input");d.setAttribute("type","text");b.appendChild(d);e.htmlFor=d;a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(c);
return d};netgis.Modal.prototype.createInputSelect=function(a,b,c){c=document.createElement("tr");var d=document.createElement("th");d.className="netgis-padding";var e=document.createElement("label");e.innerHTML=b;d.appendChild(e);c.appendChild(d);b=document.createElement("td");b.className="netgis-padding";c.appendChild(b);d=document.createElement("select");b.appendChild(d);e.htmlFor=d;a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(c);return d};
netgis.Modal.prototype.createInputInteger=function(a,b,c,d,e){var f=document.createElement("tr"),g=document.createElement("th");g.className="netgis-padding";var h=document.createElement("label");h.innerHTML=b;g.appendChild(h);f.appendChild(g);b=document.createElement("td");b.className="netgis-padding";g=document.createElement("input");g.setAttribute("type","number");g.setAttribute("min",d);g.setAttribute("max",e);g.value=Number.parseInt(c);b.appendChild(g);f.appendChild(b);h.htmlFor=g;a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(f);
return g};
netgis.Modal.prototype.createInputCheckbox=function(a,b,c){var d=document.createElement("tr"),e=document.createElement("th");e.className="netgis-padding";var f=document.createElement("label");f.innerHTML=b;e.appendChild(f);d.appendChild(e);b=document.createElement("td");b.className="netgis-padding";e=document.createElement("input");e.setAttribute("type","checkbox");e.checked=c;b.appendChild(e);d.appendChild(b);f.htmlFor=e;a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(d);return e};
netgis.Modal.prototype.createInputFile=function(a,b,c,d){var e=document.createElement("tr"),f=document.createElement("th");f.className="netgis-padding";var g=document.createElement("label");g.innerHTML=b;f.appendChild(g);e.appendChild(f);b=document.createElement("td");b.className="netgis-padding";f=document.createElement("input");f.setAttribute("type","file");f.setAttribute("accept",c);d&&f.addEventListener("change",d);b.appendChild(f);e.appendChild(b);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(e);
return f};netgis.Modal.prototype.createText=function(a,b,c){var d=document.createElement("tr"),e=document.createElement("th");e.className="netgis-padding";e.innerHTML=b;d.appendChild(e);b=document.createElement("td");b.className="netgis-padding";b.innerHTML=c;d.appendChild(b);a.getElementsByClassName("netgis-modal-content")[0].getElementsByTagName("table")[0].appendChild(d);return b};netgis.Modal.prototype.onRootClick=function(a){a.target===this.root&&this.hide()};
netgis.Modal.prototype.onHeaderClick=function(a){this.hide()};netgis.Modal.prototype.onImportGeoJSONShow=function(a){a=this.importGeoJSON.getElementsByTagName("input")[0];var b=this.importGeoJSON.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importGeoJSON)};netgis.Modal.prototype.onImportGeoJSONChange=function(a){a=this.importGeoJSON.getElementsByTagName("input")[0];this.importGeoJSON.getElementsByTagName("button")[1].disabled=a.value&&0<a.value.length?!1:!0};
netgis.Modal.prototype.onImportGeoJSONAccept=function(a){a=this.importGeoJSON.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_GEOJSON,a);this.hide()};netgis.Modal.prototype.onImportGMLShow=function(a){a=this.importGML.getElementsByTagName("input")[0];var b=this.importGML.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importGML)};
netgis.Modal.prototype.onImportGMLChange=function(a){a=this.importGML.getElementsByTagName("input")[0];this.importGML.getElementsByTagName("button")[1].disabled=a.value&&0<a.value.length?!1:!0};netgis.Modal.prototype.onImportGMLAccept=function(a){a=this.importGML.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_GML,a);this.hide()};
netgis.Modal.prototype.onImportShapefileShow=function(a){a=this.importShapefile.getElementsByTagName("input")[0];var b=this.importShapefile.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importShapefile)};netgis.Modal.prototype.onImportShapefileChange=function(a){a=this.importShapefile.getElementsByTagName("input")[0];this.importShapefile.getElementsByTagName("button")[1].disabled=a.value&&0<a.value.length?!1:!0};
netgis.Modal.prototype.onImportShapefileAccept=function(a){a=this.importShapefile.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_SHAPEFILE,a);this.hide()};netgis.Modal.prototype.onImportSpatialiteShow=function(a){a=this.importShapefile.getElementsByTagName("input")[0];var b=this.importShapefile.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importSpatialite)};
netgis.Modal.prototype.onImportSpatialiteChange=function(a){a=this.importSpatialite.getElementsByTagName("input")[0];this.importSpatialite.getElementsByTagName("button")[1].disabled=a.value&&0<a.value.length?!1:!0};netgis.Modal.prototype.onImportSpatialiteAccept=function(a){a=this.importSpatialite.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_SPATIALITE,a);this.hide()};
netgis.Modal.prototype.onImportGeopackageShow=function(a){a=this.importGeopackage.getElementsByTagName("input")[0];var b=this.importGeopackage.getElementsByTagName("button")[1];a.value="";b.disabled=!0;this.show(this.importGeopackage)};netgis.Modal.prototype.onImportGeopackageChange=function(a){a=this.importGeopackage.getElementsByTagName("input")[0];this.importGeopackage.getElementsByTagName("button")[1].disabled=a.value&&0<a.value.length?!1:!0};
netgis.Modal.prototype.onImportGeopackageAccept=function(a){a=this.importGeopackage.getElementsByTagName("input")[0].files[0];this.client.invoke(netgis.Events.IMPORT_GEOPACKAGE,a);this.hide()};netgis.Modal.prototype.onExportPDFShow=function(a){a=this.exportPDF.getElementsByTagName("input");a[0].value=this.client.map.getWidth();a[1].value=this.client.map.getHeight();a[2].value=this.client.config.export.defaultMargin;a[3].checked=!0;this.show(this.exportPDF)};
netgis.Modal.prototype.onExportJPEGShow=function(a){a=this.exportJPEG.getElementsByTagName("input");a[0].value=this.client.map.getWidth();a[1].value=this.client.map.getHeight();this.show(this.exportJPEG)};netgis.Modal.prototype.onExportPNGShow=function(a){a=this.exportPNG.getElementsByTagName("input");a[0].value=this.client.map.getWidth();a[1].value=this.client.map.getHeight();this.show(this.exportPNG)};
netgis.Modal.prototype.onExportGIFShow=function(a){a=this.exportGIF.getElementsByTagName("input");a[0].value=this.client.map.getWidth();a[1].value=this.client.map.getHeight();this.show(this.exportGIF)};netgis.Modal.prototype.onExportPDFAccept=function(a){a=this.exportPDF.getElementsByTagName("input");var b=Number.parseInt(a[0].value),c=Number.parseInt(a[1].value),d=Number.parseInt(a[2].value);this.client.invoke(netgis.Events.EXPORT_PDF,{resx:b,resy:c,mode:a[3].checked,margin:d});this.hide()};
netgis.Modal.prototype.onExportJPEGAccept=function(a){var b=this.exportJPEG.getElementsByTagName("input");a=Number.parseInt(b[0].value);b=Number.parseInt(b[1].value);this.client.invoke(netgis.Events.EXPORT_JPEG,{resx:a,resy:b});this.hide()};netgis.Modal.prototype.onExportPNGAccept=function(a){var b=this.exportPNG.getElementsByTagName("input");a=Number.parseInt(b[0].value);b=Number.parseInt(b[1].value);this.client.invoke(netgis.Events.EXPORT_PNG,{resx:a,resy:b});this.hide()};
netgis.Modal.prototype.onExportGIFAccept=function(a){var b=this.exportGIF.getElementsByTagName("input");a=Number.parseInt(b[0].value);b=Number.parseInt(b[1].value);this.client.invoke(netgis.Events.EXPORT_GIF,{resx:a,resy:b});this.hide()};netgis.Modal.prototype.onAddServiceShow=function(a){this.show(this.addService);a=this.addService.getElementsByTagName("tr");for(var b=3;b<a.length;b++)a[b].classList.add("netgis-hide")};
netgis.Modal.prototype.onAddServiceLoad=function(a){a=this.addService.getElementsByTagName("input")[0].value;var b=a.indexOf("?");-1<b&&(a=a.substr(0,b));netgis.util.request(a+"?request=GetCapabilities",this.onAddServiceCapsResponse.bind(this));console.info("Add Service Load:",a)};
netgis.Modal.prototype.onAddServiceCapsResponse=function(a){var b=(new DOMParser).parseFromString(a,"text/xml").documentElement;a=this.addService.getElementsByTagName("tr");var c=a[5],d=this.addService.getElementsByTagName("input")[1];a=this.addService.getElementsByTagName("select");var e=a[0];a=a[1];for(var f=e.options.length-1;0<=f;f--)e.options.remove(f);for(f=a.options.length-1;0<=f;f--)a.options.remove(f);switch(b.nodeName){case "WMS_Capabilities":d.value="wms";b.getAttribute("version");d=b.getElementsByTagName("Service")[0];
d=d.getElementsByTagName("Title")[0].textContent;c.children[1].innerHTML=d;f=b.getElementsByTagName("Layer");var g=[];for(d=0;d<f.length;d++){c=f[d];var h=c.getElementsByTagName("Name")[0].textContent,k=c.getElementsByTagName("Title")[0].textContent;g.push({name:h,title:k});c=document.createElement("option");c.text=k;c.value=h;e.options.add(c)}b=b.getElementsByTagName("GetMap")[0].getElementsByTagName("Format");e=[];for(d=0;d<b.length;d++)c=b[d],f=c.textContent,e.push(f),c=document.createElement("option"),
c.text=f,c.value=f,a.options.add(c);break;case "WFS_Capabilities":case "wfs:WFS_Capabilities":d.value="wfs";b.getAttribute("version");d=b.getElementsByTagName("ows:ServiceIdentification")[0];d=d.getElementsByTagName("ows:Title")[0].textContent;c.children[1].innerHTML=d;f=b.getElementsByTagName("FeatureType");g=[];for(d=0;d<f.length;d++)c=f[d],h=c.getElementsByTagName("Name")[0].textContent,k=c.getElementsByTagName("Title")[0].textContent,g.push({name:h,title:k}),c=document.createElement("option"),
c.text=k,c.value=h,e.options.add(c);b=b.getElementsByTagName("ows:Operation");e=null;for(c=0;c<b.length;c++)if("GetFeature"===b[c].getAttribute("name")){e=b[c];break}if(e)for(b=e.getElementsByTagName("ows:Parameter"),e=0;e<b.length;e++)if(c=b[e],"outputFormat"===c.getAttribute("name")){b=c.getElementsByTagName("ows:Value");for(d=0;d<b.length;d++)c=b[d],f=c.textContent,c=document.createElement("option"),c.text=f,c.value=f,a.options.add(c);break}a.value="application/json"}a=this.addService.getElementsByTagName("tr");
for(b=3;b<a.length;b++)a[b].classList.remove("netgis-hide")};
netgis.Modal.prototype.onAddServiceAccept=function(a){var b=this.addService.getElementsByTagName("input"),c=this.addService.getElementsByTagName("select");a=b[0].value;b=b[1].value;var d=c[0];c=c[1];d=d.options.item(d.options.selectedIndex);c=c.options.item(c.options.selectedIndex);a={id:this.addServiceID++,url:a,title:d.text,name:d.value,format:c.value};switch(b){case "wms":this.client.invoke(netgis.Events.ADD_SERVICE_WMS,a);break;case "wfs":this.client.invoke(netgis.Events.ADD_SERVICE_WFS,a)}this.hide()};netgis=netgis||{};netgis.Modes=Object.freeze({VIEW:"VIEW",PANNING:"PANNING",ZOOMING_IN:"ZOOMING_IN",ZOOMING_OUT:"ZOOMING_OUT",DRAW_POINTS:"DRAW_POINTS",DRAW_LINES:"DRAW_LINES",DRAW_POLYGONS:"DRAW_POLYGONS",CUT_FEATURE_BEGIN:"CUT_FEATURE_BEGIN",CUT_FEATURE_DRAW:"CUT_FEATURE_DRAW",MODIFY_FEATURES:"MODIFY_FEATURES",DELETE_FEATURES:"DELETE_FEATURES",BUFFER_FEATURE_BEGIN:"BUFFER_FEATURE_BEGIN",BUFFER_FEATURE_EDIT:"BUFFER_FEATURE_EDIT",SEARCH_PLACE:"SEARCH_PLACE",SEARCH_PARCEL:"SEARCH_PARCEL"});netgis=netgis||{};
netgis.OWS=function(){return{read:function(a,b){var c={layers:[],folders:[]};netgis.util.isDefined(a.properties)&&(c.bbox=a.properties.bbox);a=a.features;for(var d=0;d<a.length;d++){var e=a[d];if("Feature"===e.type){var f=e.properties;f=f.folder;var g=!1;for(e=0;e<c.folders.length;e++)if(c.folders[e].id===f){g=!0;break}if(!g){e=f.split("/");f=[];for(g=0;g<e.length;g++){var h=e[g];0<h.length&&f.push(h)}var k=-1;for(g=0;g<f.length;g++){h=f[g];var l="/"+f.slice(0,g+1).join("/"),m=!1;for(e=0;e<c.folders.length;e++)if(c.folders[e].path===
l){k=e;m=!0;break}m||(e=c.folders.length,c.folders.push({title:h,parent:k,path:l}),k=e)}}}}for(d=0;d<a.length;d++)if(e=a[d],"Feature"===e.type){f=e.properties;g=-1;for(e=0;e<c.folders.length;e++)if(c.folders[e].path===f.folder){g=e;break}e=f.offerings;for(h=0;h<e.length;h++)switch(k=e[h],l=k.operations,k.code){case "http://www.opengis.net/spec/owc-geojson/1.0/req/wms":c.layers.push({folder:g,type:netgis.LayerTypes.WMS,url:l[0].href,title:f.title,attribution:f.rights,active:f.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/xyz":k=
l[0];c.layers.push({folder:g,type:netgis.LayerTypes.XYZ,url:k.href,title:f.title,attribution:f.rights,active:f.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/osm":k=l[0],c.layers.push({folder:g,type:netgis.LayerTypes.XYZ,url:k.href,title:f.title,attribution:f.rights,active:f.active})}}b.invoke(netgis.Events.CONTEXT_UPDATE,c)}}}();netgis=netgis||{};netgis.SearchParcel=function(){this.client=null};
netgis.SearchParcel.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-search-parcel netgis-dialog netgis-shadow netgis-hide";var a=document.createElement("h3");a.innerHTML="Flurst\u00fccks-Suche:";this.root.appendChild(a);a=document.createElement("div");this.root.appendChild(a);var b=this.createInput("Gemarkungsname:");b.style.position="relative";a.appendChild(b);this.nameInput=b.children[0];this.nameInput.setAttribute("title","ENTER: Ausw\u00e4hlen, ESCAPE: Zur\u00fccksetzen");
this.nameInput.addEventListener("keyup",this.onInputNameKey.bind(this));this.nameLoader=document.createElement("div");this.nameLoader.className="netgis-loader netgis-text-primary netgis-hide";this.nameLoader.innerHTML="<i class='fas fa-spinner'></i>";b.appendChild(this.nameLoader);this.nameList=document.createElement("ul");a.appendChild(this.nameList);b=this.createInput("Gemarkungsnummer:");this.districtInput=b.children[0];a.appendChild(b);b=this.createInput("Flurnummer:");this.fieldInput=b.children[0];
a.appendChild(b);b=this.createInput("Flurst\u00fccksnummer (Z\u00e4hler/Nenner):");this.parcelInputA=b.children[0];this.parcelInputA.style.width="48%";this.parcelInputB=this.parcelInputA.cloneNode(!0);this.parcelInputB.style.marginLeft="4%";b.appendChild(this.parcelInputB);a.appendChild(b);b=document.createElement("button");b.setAttribute("type","button");b.addEventListener("click",this.onParcelSearchClick.bind(this));b.className="netgis-primary netgis-hover-primary";b.innerHTML="Flurst\u00fccke suchen";
b.style.marginTop="4mm";a.appendChild(b);this.parcelInfo=document.createElement("p");a.appendChild(this.parcelInfo);this.parcelTable=this.createTable(";Flur;FS Z\u00e4hler;FS Nenner;FKZ;Fl\u00e4che (qm)".split(";"));this.parcelTable.classList.add("netgis-hide");a.appendChild(this.parcelTable);this.parcelList=this.parcelTable.getElementsByTagName("tbody")[0];this.parcelReset=document.createElement("button");this.parcelReset.setAttribute("type","button");this.parcelReset.addEventListener("click",this.onParcelResetClick.bind(this));
this.parcelReset.className="netgis-primary netgis-hover-primary";this.parcelReset.innerHTML="Zur\u00fccksetzen";this.parcelReset.style.marginTop="4mm";a.appendChild(this.parcelReset);this.reset();this.client.root.appendChild(this.root);this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.LAYER_LIST_TOGGLE,this.onLayerListToggle.bind(this))};
netgis.SearchParcel.prototype.createInput=function(a){var b=document.createElement("label");b.className="netgis-hover-text-primary";b.innerHTML=a;a=document.createElement("input");a.setAttribute("type","text");b.appendChild(a);return b};
netgis.SearchParcel.prototype.createNameItem=function(a){var b=document.createElement("li"),c=document.createElement("button");c.setAttribute("type","button");c.addEventListener("click",this.onNameItemClick.bind(this));c.className="netgis-text-primary netgis-hover-light";c.innerHTML=a;b.appendChild(c);return b};
netgis.SearchParcel.prototype.createTable=function(a){var b=document.createElement("div");b.className="netgis-table-wrapper";var c=document.createElement("table");b.appendChild(c);var d=document.createElement("thead");c.appendChild(d);var e=document.createElement("tr");e.className="netgis-light";e.style.position="sticky";d.appendChild(e);for(d=0;d<a.length;d++){var f=document.createElement("th");f.innerHTML=a[d];e.appendChild(f)}a=document.createElement("tbody");c.appendChild(a);return b};
netgis.SearchParcel.prototype.createParcelItem=function(a,b,c,d,e,f,g){var h=document.createElement("tr");h.className="netgis-hover-light netgis-hover-text-primary";h.setAttribute("title","Klicken zum zoomen");h.setAttribute("data-bbox",f);h.setAttribute("data-geom",g);h.addEventListener("mouseenter",this.onParcelEnter.bind(this));h.addEventListener("mouseleave",this.onParcelLeave.bind(this));h.addEventListener("click",this.onParcelClick.bind(this));f=document.createElement("td");h.appendChild(f);
g=document.createElement("button");g.setAttribute("type","button");g.setAttribute("title","Geometrie \u00fcbernehmen");g.addEventListener("click",this.onParcelImportClick.bind(this));g.className="netgis-text-primary netgis-hover-primary";g.innerHTML="<i class='fas fa-paste'></i>";f.appendChild(g);f=document.createElement("td");f.innerHTML=a;h.appendChild(f);a=document.createElement("td");a.innerHTML=b;h.appendChild(a);b=document.createElement("td");b.innerHTML=c;h.appendChild(b);c=document.createElement("td");
c.innerHTML=d;h.appendChild(c);d=document.createElement("td");d.innerHTML=e;h.appendChild(d);return h};
netgis.SearchParcel.prototype.reset=function(){this.nameLoader.classList.add("netgis-hide");this.nameInput.value="";this.districtInput.value="";this.fieldInput.value="";this.parcelInputA.value="";this.parcelInputB.value="";this.nameList.innerHTML="";this.parcelInfo.innerHTML="";this.parcelList.innerHTML="";this.parcelTable.classList.add("netgis-hide");this.parcelReset.classList.add("netgis-hide");this.root.scrollTop=0};
netgis.SearchParcel.prototype.onInputNameKey=function(a){switch(a.keyCode){case 13:this.selectFirstName();break;case 27:this.reset();break;default:this.requestName(this.nameInput.value.trim())}};
netgis.SearchParcel.prototype.requestName=function(a){this.nameDebounce&&window.clearTimeout(this.nameDebounce);if(0!==a.length){var b=this.client.config.searchParcel.nameURL;b=netgis.util.replace(b,"{q}",window.encodeURIComponent(a));this.nameDebounce=window.setTimeout(this.onInputNameDebounce.bind(this,b),200);this.nameLoader.classList.remove("netgis-hide")}};netgis.SearchParcel.prototype.onInputNameDebounce=function(a){netgis.util.request(a,this.onInputNameResponse.bind(this))};
netgis.SearchParcel.prototype.onInputNameResponse=function(a){this.nameLoader.classList.add("netgis-hide");this.nameList.innerHTML="";if("{"===a.charAt(0)||"["===a.charAt(0)){a=JSON.parse(a);for(var b=0;b<a.data.length;b++){var c=a.data[b],d=this.createNameItem(c.gmk_name);d.getElementsByTagName("button")[0].setAttribute("data-id",c.gmk_gmn);this.nameList.appendChild(d)}}};
netgis.SearchParcel.prototype.onNameItemClick=function(a){a=a.target;var b=a.getAttribute("data-id");this.nameInput.value=a.innerHTML;this.nameList.innerHTML="";this.districtInput.value=b};netgis.SearchParcel.prototype.selectFirstName=function(){var a=this.nameList.getElementsByTagName("button");0<a.length&&a[0].click()};netgis.SearchParcel.prototype.onParcelSearchClick=function(a){this.requestParcel(this.districtInput.value.trim(),this.fieldInput.value.trim(),this.parcelInputA.value.trim(),this.parcelInputB.value.trim())};
netgis.SearchParcel.prototype.requestParcel=function(a,b,c,d){var e=this.client.config.searchParcel.parcelURL;e=netgis.util.replace(e,"{district}",a?a:"");e=netgis.util.replace(e,"{field}",b?b:"");e=netgis.util.replace(e,"{parcelA}",c?c:"");e=netgis.util.replace(e,"{parcelB}",d?d:"");this.parcelTable.classList.add("netgis-hide");this.parcelList.innerHTML="";this.parcelInfo.innerHTML="Suche Flurst\u00fccke...";netgis.util.request(e,this.onParcelResponse.bind(this))};
netgis.SearchParcel.prototype.onParcelResponse=function(a){a=JSON.parse(a);if(0===a.count)this.parcelInfo.innerHTML=a.Info;else{this.parcelInfo.innerHTML="Flurst\u00fccke gefunden: <span class='netgis-text-primary'>"+a.count+"</span>";for(var b=0;b<a.data.length;b++){var c=a.data[b];c=this.createParcelItem(c.fln,c.fsn_zae,c.fsn_nen,c.fsk,c.flaeche,c.bbox,c.geometry);this.parcelList.appendChild(c)}this.parcelTable.classList.remove("netgis-hide")}this.parcelReset.classList.remove("netgis-hide");this.root.classList.contains("netgis-hide")||
this.parcelTable.scrollIntoView()};netgis.SearchParcel.prototype.onParcelEnter=function(a){a=a.target.getAttribute("data-geom");this.client.invoke(netgis.Events.PARCEL_SHOW_PREVIEW,{geom:a})};netgis.SearchParcel.prototype.onParcelLeave=function(a){this.client.invoke(netgis.Events.PARCEL_HIDE_PREVIEW,null)};netgis.SearchParcel.prototype.onParcelClick=function(a){a=a.currentTarget.getAttribute("data-bbox");this.client.invoke(netgis.Events.MAP_ZOOM_WKT,a)};
netgis.SearchParcel.prototype.onParcelImportClick=function(a){a=a.currentTarget.parentElement.parentElement.getAttribute("data-geom");this.client.invoke(netgis.Events.IMPORT_WKT,a)};netgis.SearchParcel.prototype.onParcelResetClick=function(a){this.reset()};netgis.SearchParcel.prototype.onSetMode=function(a){a===netgis.Modes.SEARCH_PARCEL&&this.root.classList.contains("netgis-hide")?this.root.classList.remove("netgis-hide"):this.root.classList.add("netgis-hide")};
netgis.SearchParcel.prototype.onLayerListToggle=function(a){this.root.classList.add("netgis-hide")};netgis=netgis||{};netgis.SearchPlace=function(){this.lastRequest=this.timeout=this.client=null};netgis.SearchPlace.prototype.load=function(){this.client.on(netgis.Events.SEARCH_PLACE_REQUEST,this.onSearchPlaceRequest.bind(this))};
netgis.SearchPlace.prototype.request=function(a){if(this.client.config.search&&this.client.config.search.url){var b=this.client.config.search.url;a=a.trim();b=netgis.util.replace(b,"{q}",window.encodeURIComponent(a));b=netgis.util.replace(b,"{epsg}",4326);b=window.encodeURI(b);this.lastRequest=netgis.util.request(b,this.onSearchPlaceResponse.bind(this))}else console.warn("No search API url configured for place search!")};
netgis.SearchPlace.prototype.onSearchPlaceRequest=function(a){var b=a.query,c=this;this.lastRequest&&this.lastRequest.abort();this.timeout&&window.clearTimeout(this.timeout);this.timeout=window.setTimeout(function(){c.request(b)},300)};netgis.SearchPlace.prototype.onSearchPlaceResponse=function(a){a=JSON.parse(a);this.client.invoke(netgis.Events.SEARCH_PLACE_RESPONSE,a)};netgis=netgis||{};
$jscomp.polyfill("Number.isNaN",function(a){return a?a:function(a){return"number"===typeof a&&isNaN(a)}},"es6","es3");$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};$jscomp.assign="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");var netgis=netgis||{};
netgis.Attribution=function(a){this.config=a;this.layers=this.client=null;this.items=[];this.initElements(a)};netgis.Attribution.prototype.initElements=function(a){this.container=document.createElement("section");this.container.className="netgis-attribution netgis-text-a";a.attribution&&a.attribution.prefix&&this.items.push(a.attribution.prefix);this.update()};
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="&copy; "+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.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.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){netgis.util.isString(a)&&(a=document.getElementById(a));a.classList.add("netgis-client","netgis-font");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.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.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.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 600>this.container.getBoundingClientRect().width};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.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"};
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};
netgis.ContextMenu.prototype.addSlider=function(a,b,c,d,e,f){var g=document.createElement("label");g.className="netgis-noselect netgis-hover-d";var h=document.createElement("span");h.className="netgis-clip-text";h.innerHTML=b;g.appendChild(h);h=document.createElement("span");g.appendChild(h);c||0===c||(c=50);d||0===d||(d=0);e||0===e||(e=100);f||(f=1);var k=document.createElement("input");k.setAttribute("type","range");k.setAttribute("min",d);k.setAttribute("max",e);k.setAttribute("step",f);k.setAttribute("value",
c);k.setAttribute("data-id",a);k.setAttribute("data-title",b);k.setAttribute("title",b+" "+c);k.addEventListener("change",this.onSliderChange.bind(this));k.addEventListener("input",this.onSliderChange.bind(this));h.appendChild(k);this.container.appendChild(g);return k};netgis.ContextMenu.prototype.setVisible=function(a){a?this.container.classList.remove("netgis-hide"):this.container.classList.add("netgis-hide")};
netgis.ContextMenu.prototype.setPosition=function(a,b){var c=this.container.parentNode.getBoundingClientRect(),d=this.container.getBoundingClientRect();a+d.width>c.width&&(a-=d.width);b+d.height>c.height&&(b-=d.height);this.container.style.left=a+"px";this.container.style.top=b+"px"};
netgis.ContextMenu.prototype.onContextMenuShow=function(a){a=a.detail;this.clear();for(var b=0;b<a.items.length;b++){var c=a.items[b];switch(c.type){case "slider":this.addSlider(c.id,c.title,c.val,c.min,c.max)}}this.setVisible(!0);this.setPosition(a.x,a.y)};netgis.ContextMenu.prototype.onContextMenu=function(a){a.preventDefault();var b=a.clientX;a=a.clientY;this.setVisible(!0);this.setPosition(b,a);return!1};
netgis.ContextMenu.prototype.onParentClick=function(a){this.container.contains(a.target)||this.setVisible(!1)};netgis.ContextMenu.prototype.onParentScroll=function(a){this.setVisible(!1)};netgis.ContextMenu.prototype.onParentKeyDown=function(a){27===(a.keyCode||a.which)&&this.setVisible(!1)};
netgis.ContextMenu.prototype.onButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");this.setVisible(!1);netgis.util.invoke(a,netgis.Events.CONTEXTMENU_BUTTON_CLICK,{id:b});netgis.Client.handleCommand(a,b)};netgis.ContextMenu.prototype.onCheckboxChange=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.CONTEXTMENU_CHECKBOX_CHANGE,{id:b,checked:a.checked})};
netgis.ContextMenu.prototype.onSliderChange=function(a){a=a.currentTarget;var b=a.getAttribute("data-id"),c=Number.parseFloat(a.value),d=a.getAttribute("data-title");a.setAttribute("title",d+" "+c);netgis.util.invoke(a,netgis.Events.CONTEXTMENU_SLIDER_CHANGE,{id:b,val:c})};netgis=netgis||{};netgis.Controls=function(a){this.config=a;this.initElements();this.initConfig(a)};netgis.Controls.Events=Object.freeze({BUTTON_CLICK:"controls-button-click"});netgis.Controls.prototype.initElements=function(){this.container=document.createElement("section");this.container.className="netgis-controls netgis-color-e netgis-text-a netgis-shadow netgis-round"};
netgis.Controls.prototype.initConfig=function(a){a=a.controls.buttons;for(var b=0;b<a.length;b++){var c=a[b];this.addButton(c.id,c.icon,c.title)}};netgis.Controls.prototype.attachTo=function(a){a.appendChild(this.container)};
netgis.Controls.prototype.addButton=function(a,b,c){var d=document.createElement("button");d.setAttribute("type","button");d.setAttribute("data-id",a);d.className="netgis-hover-a";d.innerHTML=b;d.title=c;d.addEventListener("pointerdown",this.onButtonClick.bind(this));this.container.appendChild(d);return d};
netgis.Controls.prototype.onButtonClick=function(a){a=a.currentTarget;switch(a.getAttribute("data-id")){case "zoom_in":netgis.util.invoke(a,netgis.Events.MAP_ZOOM,{delta:1});break;case "zoom_out":netgis.util.invoke(a,netgis.Events.MAP_ZOOM,{delta:-1});break;case "zoom_home":netgis.util.invoke(a,netgis.Events.MAP_ZOOM_HOME,null)}};netgis=netgis||{};
netgis.Events=Object.freeze({CLIENT_CONTEXT_RESPONSE:"client-context-response",CLIENT_SET_MODE:"client-set-mode",CONTROLS_BUTTON_CLICK:"controls-button-click",MAP_ZOOM:"map-zoom",MAP_ZOOM_HOME:"map-zoom-home",MAP_ZOOM_LONLAT:"map-zoom-lonlat",MAP_ZOOM_SCALE:"map-zoom-scale",MAP_ZOOM_LAYER:"map-zoom-layer",MAP_ZOOM_LEVEL:"map-zoom-level",MAP_LAYER_TOGGLE:"map-layer-toggle",MAP_LAYER_TRANSPARENCY:"map-layer-transparency",MAP_VIEW_CHANGE:"map-view-change",MAP_VIEW_NEXT:"map-view-next",MAP_VIEW_PREV:"map-view-prev",
MAP_CLICK:"map-click",MAP_FEATURE_ENTER:"map-feature-enter",MAP_FEATURE_CLICK:"map-feature-click",MAP_FEATURE_LEAVE:"map-feature-leave",MAP_SNAP_TOGGLE:"map-snap-toggle",MAP_EDIT_LAYER_CHANGE:"map-edit-layer-change",MAP_EDIT_LAYER_LOADED:"map-edit-layer-loaded",MAP_COPY_FEATURE_TO_EDIT:"map-copy-feature-to-edit",PANEL_TOGGLE:"panel-toggle",PANEL_RESIZE:"panel-resize",TREE_ITEM_CHANGE:"tree-item-change",TREE_ITEM_SLIDER_CHANGE:"tree-item-slider-change",TREE_BUTTON_CLICK:"tree-button-click",LAYERTREE_TOGGLE:"layertree-toggle",
TOOLBOX_TOGGLE:"toolbox-toggle",TOOLBOX_BUTTON_CLICK:"toolbox-button-click",MENU_BUTTON_CLICK:"menu-button-click",MENU_CHECKBOX_CHANGE:"menu-checkbox-change",MENU_SELECT_CHANGE:"menu-select-change",CONTEXTMENU_SHOW:"contextmenu-show",CONTEXTMENU_BUTTON_CLICK:"contextmenu-button-click",CONTEXTMENU_CHECKBOX_CHANGE:"contextmenu-checkbox-change",CONTEXTMENU_SLIDER_CHANGE:"contextmenu-slider-change",SEARCH_CHANGE:"search-change",SEARCH_SELECT:"search-select",SEARCH_CLEAR:"search-clear",SEARCHPLACE_TOGGLE:"searchplace-toggle",
SEARCHPARCEL_TOGGLE:"searchparcel-toggle",SEARCHPARCEL_RESET:"searchparcel-reset",SEARCHPARCEL_PARCELS_RESPONSE:"searchparcel-parcels-response",SEARCHPARCEL_ITEM_ENTER:"searchparcel-item-enter",SEARCHPARCEL_ITEM_LEAVE:"searchparcel-item-leave",SEARCHPARCEL_ITEM_CLICK:"searchparcel-item-click",SEARCHPARCEL_ITEM_IMPORT:"searchparcel-item-import",MEASURE_CLEAR:"measure-clear",DRAW_BUFFER_TOGGLE:"draw-buffer-toggle",DRAW_BUFFER_CHANGE:"draw-buffer-change",BUFFER_CHANGE:"buffer-change",BUFFER_ACCEPT:"buffer-accept",
IMPORT_LAYER_SHOW:"import-layer-show",IMPORT_LAYER_ACCEPT:"import-layer-accept",IMPORT_LAYER_PREVIEW:"import-layer-preview",IMPORT_LAYER_PREVIEW_FEATURES:"import-layer-preview-features",IMPORT_GEOPORTAL_SUBMIT:"import-geoportal-submit",EXPORT_SHOW:"export-show",EXPORT_BEGIN:"export-begin",EXPORT_END:"export-end",TIMESLIDER_SHOW:"timeslider-show",TIMESLIDER_HIDE:"timeslider-hide",TIMESLIDER_SELECT:"timeslider-select"});netgis=netgis||{};netgis.Export=function(a){this.config=a;this.initElements(a);this.initSections()};
netgis.Export.prototype.initElements=function(a){a=a["export"];this.modal=new netgis.Modal(a.title?a.title:"Export");this.modal.container.classList.add("netgis-export");this.tabs=new netgis.Tabs(["PDF","JPEG","PNG","GIF","GeoJSON"]);this.tabs.container.style.position="absolute";this.tabs.container.style.left="0mm";this.tabs.container.style.right="0mm";this.tabs.container.style.top="12mm";this.tabs.container.style.bottom="0mm";this.tabs.attachTo(this.modal.content)};
netgis.Export.prototype.initSections=function(){this.sections={};var a=0;this.sections.pdf=this.tabs.getContentSection(a);a+=1;this.addInputNumber(this.sections.pdf,"Breite (Pixel):",1600,0);this.addInputNumber(this.sections.pdf,"H\u00f6he (Pixel):",900,0);this.addInputNumber(this.sections.pdf,"Seitenr\u00e4nder (Millimeter):",10,0);this.addCheckbox(this.sections.pdf,"Querformat",!0);this.addButton(this.sections.pdf,"<i class='netgis-icon fas fa-save'></i><span>Exportieren</span>",this.onExportClickPDF.bind(this));
this.sections.jpeg=this.tabs.getContentSection(a);a+=1;this.addInputNumber(this.sections.jpeg,"Breite (Pixel):",1600,0);this.addInputNumber(this.sections.jpeg,"H\u00f6he (Pixel):",900,0);this.addCheckbox(this.sections.jpeg,"Querformat",!0);this.addButton(this.sections.jpeg,"<i class='netgis-icon fas fa-save'></i><span>Exportieren</span>",this.onExportClickJPEG.bind(this));this.sections.png=this.tabs.getContentSection(a);a+=1;this.addInputNumber(this.sections.png,"Breite (Pixel):",1600,0);this.addInputNumber(this.sections.png,
"H\u00f6he (Pixel):",900,0);this.addCheckbox(this.sections.png,"Querformat",!0);this.addButton(this.sections.png,"<i class='netgis-icon fas fa-save'></i><span>Exportieren</span>",this.onExportClickPNG.bind(this));this.sections.gif=this.tabs.getContentSection(a);a+=1;this.addInputNumber(this.sections.gif,"Breite (Pixel):",1600,0);this.addInputNumber(this.sections.gif,"H\u00f6he (Pixel):",900,0);this.addCheckbox(this.sections.gif,"Querformat",!0);this.addButton(this.sections.gif,"<i class='netgis-icon fas fa-save'></i><span>Exportieren</span>",
this.onExportClickGIF.bind(this));this.sections.geojson=this.tabs.getContentSection(a);this.addCheckbox(this.sections.geojson,"Nicht-Editierbare Geometrien einbeziehen",!1);this.addButton(this.sections.geojson,"<i class='netgis-icon fas fa-save'></i><span>Exportieren</span>",this.onExportClickGeoJSON.bind(this))};
netgis.Export.prototype.attachTo=function(a){a.appendChild(this.modal.container);a.addEventListener(netgis.Events.EXPORT_SHOW,this.onExportShow.bind(this));a.addEventListener(netgis.Events.EXPORT_END,this.onExportEnd.bind(this))};netgis.Export.prototype.addText=function(a,b){var c=document.createElement("div");c.innerHTML=b;a.appendChild(c);return c};
netgis.Export.prototype.addButton=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";d.setAttribute("type","button");d.innerHTML=b;c&&(d.onclick=c);a.appendChild(d);return d};
netgis.Export.prototype.addInputText=function(a,b,c){var d=document.createElement("label");d.innerHTML=b;var e=document.createElement("input");e.setAttribute("type","text");d.appendChild(e);if(c){b="list-"+netgis.util.stringToID(b);var f=document.createElement("datalist");f.setAttribute("id",b);for(var g=0;g<c.length;g++){var h=document.createElement("option");h.setAttribute("value",c[g]);f.appendChild(h)}a.appendChild(f);e.setAttribute("list",b)}a.appendChild(d);return e};
netgis.Export.prototype.addInputNumber=function(a,b,c,d,e){var f=document.createElement("label");f.innerHTML=b;b=document.createElement("input");b.setAttribute("type","number");(d||0===d)&&b.setAttribute("min",d);e&&b.setAttribute("max",e);b.setAttribute("value",c);f.appendChild(b);a.appendChild(f);return b};
netgis.Export.prototype.addCheckbox=function(a,b,c){var d=document.createElement("label"),e=document.createElement("input");e.setAttribute("type","checkbox");e.checked=c;d.appendChild(e);c=document.createElement("span");c.innerHTML=b;d.appendChild(c);a.appendChild(d);return e};netgis.Export.prototype.onExportShow=function(a){this.modal.show()};
netgis.Export.prototype.onExportClickPDF=function(a){var b=this.sections.pdf.getElementsByTagName("input");b={format:"pdf",width:Number.parseInt(b[0].value),height:Number.parseInt(b[1].value),padding:Number.parseInt(b[2].value),landscape:b[3].checked};netgis.util.invoke(a.target,netgis.Events.EXPORT_BEGIN,b)};
netgis.Export.prototype.onExportClickJPEG=function(a){var b=this.sections.pdf.getElementsByTagName("input");b={format:"jpeg",width:Number.parseInt(b[0].value),height:Number.parseInt(b[1].value),landscape:b[3].checked};netgis.util.invoke(a.target,netgis.Events.EXPORT_BEGIN,b)};
netgis.Export.prototype.onExportClickPNG=function(a){var b=this.sections.pdf.getElementsByTagName("input");b={format:"png",width:Number.parseInt(b[0].value),height:Number.parseInt(b[1].value),landscape:b[3].checked};netgis.util.invoke(a.target,netgis.Events.EXPORT_BEGIN,b)};
netgis.Export.prototype.onExportClickGIF=function(a){var b=this.sections.pdf.getElementsByTagName("input");b={format:"gif",width:Number.parseInt(b[0].value),height:Number.parseInt(b[1].value),landscape:b[3].checked};netgis.util.invoke(a.target,netgis.Events.EXPORT_BEGIN,b)};netgis.Export.prototype.onExportClickGeoJSON=function(a){var b={format:"geojson",nonEdits:this.sections.geojson.getElementsByTagName("input")[0].checked};netgis.util.invoke(a.target,netgis.Events.EXPORT_BEGIN,b)};
netgis.Export.prototype.onExportEnd=function(a){this.modal.hide()};netgis=netgis||{};netgis.Import=function(a){this.config=a;this.initElements(a);this.initSections();this.initPreview()};
netgis.Import.prototype.initElements=function(a){a=a["import"];this.modal=new netgis.Modal(a.title?a.title:"Import");this.modal.container.classList.add("netgis-import");var b="WMS WFS GeoJSON GML GeoPackage Spatialite Shapefile".split(" ");a.geoportal_tab&&b.unshift("Geoportal");this.tabs=new netgis.Tabs(b);this.tabs.container.style.position="absolute";this.tabs.container.style.left="0mm";this.tabs.container.style.right="0mm";this.tabs.container.style.top="12mm";this.tabs.container.style.bottom="0mm";
this.tabs.attachTo(this.modal.content)};
netgis.Import.prototype.initSections=function(){this.sections={};var a=0;this.config["import"].geoportal_tab&&(this.sections.geoportal=this.tabs.getContentSection(a),a+=1,this.sections.geoportal.classList.add("netgis-geoportal"),this.geoportalSearch=this.addInputText(this.sections.geoportal,"Suche im Datenkatalog:"),this.geoportalSearch.addEventListener("change",this.onGeoportalSearchChange.bind(this)),this.geoportalSearch.setAttribute("placeholder","Thema, Schlagwort..."),this.geoportalResults=new netgis.Tree,
this.geoportalResults.attachTo(this.sections.geoportal),this.geoportalSubmit=this.addButton(this.sections.geoportal,"<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>",this.onGeoportalSubmit.bind(this)));this.sections.wms=this.tabs.getContentSection(a);a+=1;this.addInputText(this.sections.wms,"WMS-URL:",this.config["import"].wms_options);this.addButton(this.sections.wms,"<i class='netgis-icon fas fa-cloud-download-alt'></i><span>Dienst laden</span>",this.onWMSLoadClick.bind(this));
this.addInputText(this.sections.wms,"Bezeichnung:");this.addInputSelect(this.sections.wms,"Ebene:");this.addInputSelect(this.sections.wms,"Format:");this.addButton(this.sections.wms,"<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>",this.onWMSAcceptClick.bind(this));this.showDetailsWMS(!1);this.sections.wfs=this.tabs.getContentSection(a);a+=1;this.addInputText(this.sections.wfs,"WFS-URL:",this.config["import"].wfs_options);this.addButton(this.sections.wfs,"<i class='netgis-icon fas fa-cloud-download-alt'></i><span>Dienst laden</span>",
this.onWFSLoadClick.bind(this));this.addInputText(this.sections.wfs,"Bezeichnung:");this.addInputSelect(this.sections.wfs,"Ebene:");this.addInputSelect(this.sections.wfs,"Format:");this.addButton(this.sections.wfs,"<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>",this.onWFSAcceptClick.bind(this));this.showDetailsWFS(!1);this.sections.geojson=this.tabs.getContentSection(a);a+=1;this.addInputFile(this.sections.geojson,"GeoJSON-Datei:",".geojson,.json");this.addText(this.sections.geojson,
"<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>Web Mercator (EPSG:3857)</li><li>WGS84 / Lon-Lat (EPSG:4326)</li><li>ETRS89 / UTM Zone 32N (EPSG:25832)</li></ul>");this.addButton(this.sections.geojson,"<i class='netgis-icon fas fa-check'></i><span>Datei laden</span>",this.onGeoJSONAcceptClick.bind(this));this.sections.gml=this.tabs.getContentSection(a);a+=1;this.addInputFile(this.sections.gml,"GML-Datei:",".gml,.xml");this.addText(this.sections.gml,"<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>Web Mercator (EPSG:3857)</li><li>WGS84 / Lon-Lat (EPSG:4326)</li><li>ETRS89 / UTM Zone 32N (EPSG:25832)</li></ul>");
this.addButton(this.sections.gml,"<i class='netgis-icon fas fa-check'></i><span>Datei laden</span>",this.onGMLAcceptClick.bind(this));this.sections.geopackage=this.tabs.getContentSection(a);a+=1;this.addInputFile(this.sections.geopackage,"GeoPackage-Datei:",".gpkg");this.addText(this.sections.geopackage,"<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>Web Mercator (EPSG:3857)</li><li>WGS84 / Lon-Lat (EPSG:4326)</li><li>ETRS89 / UTM Zone 32N (EPSG:25832)</li></ul>");this.addButton(this.sections.geopackage,
"<i class='netgis-icon fas fa-check'></i><span>Datei laden</span>",this.onGeoPackageAcceptClick.bind(this));this.sections.spatialite=this.tabs.getContentSection(a);a+=1;this.addInputFile(this.sections.spatialite,"Spatialite-Datei:",".sqlite");this.addText(this.sections.spatialite,"<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>Web Mercator (EPSG:3857)</li><li>WGS84 / Lon-Lat (EPSG:4326)</li><li>ETRS89 / UTM Zone 32N (EPSG:25832)</li></ul>");this.addButton(this.sections.spatialite,"<i class='netgis-icon fas fa-check'></i><span>Datei laden</span>",
this.onSpatialiteAcceptClick.bind(this));this.sections.shapefile=this.tabs.getContentSection(a);this.addInputFile(this.sections.shapefile,"Shapefile-Zip-Datei:",".zip");this.addText(this.sections.shapefile,"<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>Web Mercator (EPSG:3857)</li><li>WGS84 / Lon-Lat (EPSG:4326)</li><li>ETRS89 / UTM Zone 32N (EPSG:25832)</li></ul>");this.addButton(this.sections.shapefile,"<i class='netgis-icon fas fa-check'></i><span>Datei laden</span>",this.onShapefileAcceptClick.bind(this))};
netgis.Import.prototype.initPreview=function(){this.preview=new netgis.Modal("Vorschau");this.preview.attachTo(this.modal.content);this.previewMapContainer=document.createElement("div");this.previewMapContainer.className="netgis-preview-map";this.preview.content.appendChild(this.previewMapContainer);if(ol){var a=this.config.map;a={projection:a.projection,center:a.centerLonLat?ol.proj.fromLonLat(a.centerLonLat):a.center,zoom:a.zoom};this.previewMap=new ol.Map({target:this.previewMapContainer,view:new ol.View(a),
pixelRatio:1,moveTolerance:3,controls:[]});this.previewMap.getView().padding=[10,10,10,10];this.previewMap.addLayer(new ol.layer.Tile({source:new ol.source.OSM}))}this.previewTree=new netgis.Tree;this.previewTree.container.classList.add("netgis-preview-tree");this.previewTree.attachTo(this.preview.content);this.previewTree.container.addEventListener(netgis.Events.TREE_ITEM_CHANGE,this.onPreviewTreeItemChange.bind(this));this.previewSubmit=document.createElement("button");this.previewSubmit.setAttribute("type",
"button");this.previewSubmit.className="netgis-import-submit netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";this.previewSubmit.innerHTML="<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>";this.previewSubmit.addEventListener("click",this.onPreviewSubmitClick.bind(this));this.preview.content.appendChild(this.previewSubmit)};
netgis.Import.prototype.attachTo=function(a){a.appendChild(this.modal.container);a.addEventListener(netgis.Events.IMPORT_LAYER_SHOW,this.onImportShow.bind(this));a.addEventListener(netgis.Events.IMPORT_LAYER_PREVIEW_FEATURES,this.onImportPreviewFeatures.bind(this))};netgis.Import.prototype.addText=function(a,b){var c=document.createElement("div");c.innerHTML=b;a.appendChild(c);return c};
netgis.Import.prototype.addButton=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";d.setAttribute("type","button");d.innerHTML=b;c&&(d.onclick=c);a.appendChild(d);return d};
netgis.Import.prototype.addInputText=function(a,b,c){var d=document.createElement("label");d.innerHTML=b;var e=document.createElement("input");e.setAttribute("type","text");d.appendChild(e);if(c){b="list-"+netgis.util.stringToID(b);var f=document.createElement("datalist");f.setAttribute("id",b);for(var g=0;g<c.length;g++){var h=document.createElement("option");h.setAttribute("value",c[g]);f.appendChild(h)}a.appendChild(f);e.setAttribute("list",b)}a.appendChild(d);return e};
netgis.Import.prototype.addInputSelect=function(a,b,c){c=document.createElement("label");c.innerHTML=b;b=document.createElement("select");c.appendChild(b);a.appendChild(c);return b};netgis.Import.prototype.addInputFile=function(a,b,c){var d=document.createElement("label");d.innerHTML=b;b=document.createElement("input");b.setAttribute("type","file");b.setAttribute("accept",c);d.appendChild(b);a.appendChild(d);return b};netgis.Import.prototype.getLayerOrder=function(){return 1E4};
netgis.Import.prototype.showDetailsWMS=function(a){var b=this.sections.wms,c=b.getElementsByTagName("label");b=b.getElementsByTagName("button");a?(c[1].classList.remove("netgis-hide"),c[2].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide"),b[1].classList.remove("netgis-hide")):(c[1].classList.add("netgis-hide"),c[2].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"),b[1].classList.add("netgis-hide"))};
netgis.Import.prototype.showDetailsWFS=function(a){var b=this.sections.wfs,c=b.getElementsByTagName("label");b=b.getElementsByTagName("button");a?(c[1].classList.remove("netgis-hide"),c[2].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide"),b[1].classList.remove("netgis-hide")):(c[1].classList.add("netgis-hide"),c[2].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"),b[1].classList.add("netgis-hide"))};
netgis.Import.prototype.submitImportLayer=function(a){!0===this.config["import"].preview?netgis.util.invoke(this.modal.container,netgis.Events.IMPORT_LAYER_PREVIEW,a):(this.config.layers.push(a),netgis.util.invoke(this.modal.container,netgis.Events.IMPORT_LAYER_ACCEPT,a),this.modal.hide())};netgis.Import.prototype.onImportShow=function(a){this.modal.show();this.tabs.updateHeaderScroll()};
netgis.Import.prototype.onWMSLoadClick=function(a){this.showDetailsWMS(!1);var b=this.sections.wms.getElementsByTagName("input")[0].value;b=b.trim();if(!(1>b.length)){var c=b.indexOf("?");a=-1<c?b.substr(0,c):b;var d=["request=GetCapabilities"];if(-1<c)for(b=b.substr(c+1),b=b.split("&"),c=0;c<b.length;c++){var e=b[c];e=e.toLowerCase();-1<e.search("service")?d.push(e):-1<e.search("version")?d.push(e):e.search("request")}d=d.join("&");-1===d.search("service=")&&(d+="&service=WMS");netgis.util.request(a+
"?"+d,this.onWMSCapsResponse.bind(this))}};
netgis.Import.prototype.onWMSCapsResponse=function(a){var b=(new DOMParser).parseFromString(a,"text/xml"),c=b.documentElement;b=b.getElementsByTagName("parsererror");for(var d=0;d<b.length;d++)console.error("WMS caps parser error:",b[d].textContent);0<b.length&&alert(0<a.length?a:b[0].textContent);a=this.sections.wms;var e=a.getElementsByTagName("input");a=a.getElementsByTagName("select");b=a[0];a=a[1];for(d=b.options.length-1;0<=d;d--)b.options.remove(d);for(d=a.options.length-1;0<=d;d--)a.options.remove(d);
switch(c.nodeName){default:case "HTML":console.warn("could not detect WMS service",c);break;case "WMS_Capabilities":case "WMT_MS_Capabilities":c.getAttribute("version");d=c.getElementsByTagName("Service")[0].getElementsByTagName("Title")[0].textContent;e[1].value=d;d=c.getElementsByTagName("Layer");for(var f=[],g=0;g<d.length;g++){e=d[g];var h=e.getElementsByTagName("Name")[0].textContent,k=e.getElementsByTagName("Title")[0].textContent;f.push({name:h,title:k});e=document.createElement("option");
e.text=k;e.value=h;b.options.add(e)}c=c.getElementsByTagName("GetMap")[0].getElementsByTagName("Format");b=[];for(d=0;d<c.length;d++)e=c[d],f=e.textContent,b.push(f),e=document.createElement("option"),e.text=f,e.value=f,a.options.add(e)}this.showDetailsWMS(!0)};
netgis.Import.prototype.onWMSAcceptClick=function(a){a=this.sections.wms;var b=a.getElementsByTagName("input"),c=a.getElementsByTagName("select"),d="import_"+netgis.util.getTimeStamp(!0);b=b[0].value;var e=c[0].selectedOptions[0].innerText,f=c[0].value;c=c[1].value;b=netgis.util.replace(b,"request=","oldrequest=");b=netgis.util.replace(b,"Request=","oldrequest=");d={id:d,folder:null,active:!0,order:this.getLayerOrder(),type:netgis.LayerTypes.WMS,url:b,title:e,name:f,format:c,tiled:!0};this.config.layers.push(d);
netgis.util.invoke(a,netgis.Events.IMPORT_LAYER_ACCEPT,d);this.modal.hide()};
netgis.Import.prototype.onWFSLoadClick=function(a){this.showDetailsWFS(!1);var b=this.sections.wfs.getElementsByTagName("input")[0].value;b=b.trim();if(!(1>b.length)){var c=b.indexOf("?");a=-1<c?b.substr(0,c):b;var d=["request=GetCapabilities"];if(-1<c)for(b=b.substr(c+1),b=b.split("&"),c=0;c<b.length;c++){var e=b[c];e=e.toLowerCase();-1<e.search("service")?d.push(e):-1<e.search("version")?d.push(e):-1<e.search("request")||d.push(e)}d=d.join("&");-1===d.search("service=")&&(d+="&service=WFS");a=a+
"?"+d;this.config["import"].wfs_proxy&&(a=this.config["import"].wfs_proxy+a);netgis.util.request(a,this.onWFSCapsResponse.bind(this))}};
netgis.Import.prototype.onWFSCapsResponse=function(a){var b=(new DOMParser).parseFromString(a,"text/xml"),c=b.documentElement;b=b.getElementsByTagName("parsererror");for(var d=0;d<b.length;d++)console.error("WFS caps parser error:",b[d].textContent);0<b.length&&alert(0<a.length?a:b[0].textContent);a=this.sections.wfs;var e=a.getElementsByTagName("input");a=a.getElementsByTagName("select");b=a[0];a=a[1];for(d=b.options.length-1;0<=d;d--)b.options.remove(d);for(d=a.options.length-1;0<=d;d--)a.options.remove(d);
switch(c.nodeName){default:case "HTML":console.error("could not detect WFS service",c);break;case "WFS_Capabilities":case "wfs:WFS_Capabilities":c.getAttribute("version");d=c.getElementsByTagName("ows:ServiceIdentification")[0].getElementsByTagName("ows:Title")[0].textContent;e[1].value=d;d=c.getElementsByTagName("FeatureType");for(var f=[],g=0;g<d.length;g++){e=d[g];var h=e.getElementsByTagName("Name")[0].textContent,k=e.getElementsByTagName("Title")[0].textContent;f.push({name:h,title:k});e=document.createElement("option");
e.text=k;e.value=h;b.options.add(e)}c=c.getElementsByTagName("ows:Operation");b=null;for(e=0;e<c.length;e++)if("GetFeature"===c[e].getAttribute("name")){b=c[e];break}c=null;if(b)for(b=b.getElementsByTagName("ows:Parameter"),e=0;e<b.length;e++)if(d=b[e],"outputFormat"===d.getAttribute("name")){b=d.getElementsByTagName("ows:Value");for(d=0;d<b.length;d++)e=b[d],f=e.textContent,e=document.createElement("option"),e.text=f,e.value=f,a.options.add(e),-1<f.search("json")&&(c=f);break}c&&(a.value=c)}this.showDetailsWFS(!0)};
netgis.Import.prototype.onWFSAcceptClick=function(a){a=this.sections.wfs;var b=a.getElementsByTagName("input"),c=a.getElementsByTagName("select"),d="import_"+netgis.util.getTimeStamp(!0);b=b[0].value;var e=c[0].selectedOptions[0].innerText,f=c[0].value;c=c[1].value;b=netgis.util.replace(b,"request=","oldrequest=");b=netgis.util.replace(b,"Request=","oldrequest=");this.config["import"].wfs_proxy&&(b=this.config["import"].wfs_proxy+b);d={id:d,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],
title:e,type:netgis.LayerTypes.WFS,url:b,name:f,format:c};this.config.layers.push(d);netgis.util.invoke(a,netgis.Events.IMPORT_LAYER_ACCEPT,d);this.modal.hide()};netgis.Import.prototype.onGeoJSONAcceptClick=function(a){if(a=this.sections.geojson.getElementsByTagName("input")[0].files[0]){var b=new FileReader;b.title=a.name;b.onload=this.onGeoJSONLoad.bind(this);b.readAsText(a)}else alert("No file selected!")};
netgis.Import.prototype.onGeoJSONLoad=function(a){var b=a.target;a=b.title;b=b.result;a={id:"import_"+netgis.util.getTimeStamp(!0),folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:a,type:netgis.LayerTypes.GEOJSON,data:b};this.submitImportLayer(a)};netgis.Import.prototype.onGMLAcceptClick=function(a){if(a=this.sections.gml.getElementsByTagName("input")[0].files[0]){var b=new FileReader;b.title=a.name;b.onload=this.onGMLLoad.bind(this);b.readAsText(a)}else alert("No file selected!")};
netgis.Import.prototype.onGMLLoad=function(a){var b=a.target;a=b.result;var c="import_"+netgis.util.getTimeStamp(!0);b=b.title;a={id:c,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:b,type:netgis.LayerTypes.GML,data:a};this.submitImportLayer(a)};netgis.Import.prototype.onGeoPackageAcceptClick=function(a){if(a=this.sections.geopackage.getElementsByTagName("input")[0].files[0]){var b=new FileReader;b.title=a.name;b.onload=this.onGeoPackageLoad.bind(this);b.readAsArrayBuffer(a)}else alert("No file selected!")};
netgis.Import.prototype.onGeoPackageLoad=function(a){var b=a.target;a=b.result;var c="import_"+netgis.util.getTimeStamp(!0);b=b.title;a={id:c,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:b,type:netgis.LayerTypes.GEOPACKAGE,data:a};this.submitImportLayer(a)};
netgis.Import.prototype.onSpatialiteAcceptClick=function(a){if(a=this.sections.spatialite.getElementsByTagName("input")[0].files[0]){var b=new FileReader;b.title=a.name;b.onload=this.onSpatialiteLoad.bind(this);b.readAsArrayBuffer(a)}else alert("No file selected!")};
netgis.Import.prototype.onSpatialiteLoad=function(a){var b=a.target;a=b.result;var c="import_"+netgis.util.getTimeStamp(!0);b=b.title;a={id:c,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:b,type:netgis.LayerTypes.SPATIALITE,data:a};this.submitImportLayer(a)};
netgis.Import.prototype.onShapefileAcceptClick=function(a){if(a=this.sections.shapefile.getElementsByTagName("input")[0].files[0]){var b=new FileReader;b.title=a.name;b.onload=this.onShapefileLoad.bind(this);b.readAsArrayBuffer(a)}else alert("No file selected!")};
netgis.Import.prototype.onShapefileLoad=function(a){var b=a.target;a=b.result;var c="import_"+netgis.util.getTimeStamp(!0);b=b.title;a={id:c,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:b,type:netgis.LayerTypes.SHAPEFILE,data:a};this.submitImportLayer(a)};
netgis.Import.prototype.onImportPreviewFeatures=function(a){var b=a.detail,c=b.layer;this.previewTree.clear();a=this.previewMap.getLayers().getArray();for(var d=1;d<a.length;d++)this.previewMap.removeLayer(a[d]);if(ol){a=config.styles["import"];a=new ol.style.Style({fill:new ol.style.Fill({color:a.fill}),stroke:new ol.style.Stroke({color:a.stroke,width:a.width})});c.setStyle(a);this.previewMap.addLayer(c);var e=this.previewTree.addFolder(null,b.id,b.title);a=c.getSource().getFeatures();if(0===a.length){var f=
this;c.getSource().on("addfeature",function(a){f.featureLoadTimeout&&window.clearTimeout(f.featureLoadTimeout);f.featureLoadTimeout=window.setTimeout(function(){var a=c.getSource().getFeatures();f.updatePreviewFeatures(a,e,c,b);f.featureLoadTimeout=null},100)})}else this.updatePreviewFeatures(a,e,c,b)}else console.error("import preview only supported with OL map renderer",c)};
netgis.Import.prototype.updatePreviewFeatures=function(a,b,c,d){for(var e=0;e<a.length;e++){var f=a[e],g=f.getId(),h=f.getProperties();g||(g=e+1,f.setId(g));var k=null,l;for(l in h)switch(l.toLowerCase()){case "name":k=h[l];break;case "title":k=h[l];break;case "id":k=h[l];break;case "gid":k=h[l];break;case "oid":k=h[l];break;case "objectid":k=h[l]}k||(k=g);h=f.getGeometry();if(h instanceof ol.geom.Polygon||h instanceof ol.geom.MultiPolygon)k+=" ("+netgis.util.formatArea(h.getArea())+")";else if(h instanceof
ol.geom.LineString)k+=" ("+netgis.util.formatArea(h.getLength())+")";else if(h instanceof ol.geom.MultiLineString){f=0;h=h.getLineStrings();for(var m=0;m<h.length;m++)f+=h[m].getLength();k+=" ("+netgis.util.formatArea(f)+")"}this.previewTree.addCheckbox(b,g,"Feature "+k,!0)}this.previewTree.setFolderOpen(d.id,!0);this.previewTree.updateFolderChecks();this.preview.show();this.previewMap.updateSize();this.previewMap.getView().fit(c.getSource().getExtent())};
netgis.Import.prototype.onPreviewSubmitClick=function(a){var b=this.previewTree.container.getElementsByClassName("netgis-folder")[0];a=b.getAttribute("data-id");b=b.getElementsByTagName("span")[0].innerText;for(var c=this.previewTree.container.getElementsByTagName("input"),d=this.previewMap.getLayers().getArray()[1].getSource(),e=[],f=1;f<c.length;f++){var g=c[f];g.checked&&(g=g.getAttribute("data-id"),g=d.getFeatureById(g),e.push(g))}c=(new ol.format.GeoJSON).writeFeaturesObject(e);d=this.previewMap.getView().getProjection().getCode();
c.crs={type:"name",properties:{name:"urn:ogc:def:crs:"+d.replace(":","::")}};a={id:a,folder:null,active:!0,order:this.getLayerOrder(),style:this.config.styles["import"],title:b,type:netgis.LayerTypes.GEOJSON,data:c};this.config.layers.push(a);netgis.util.invoke(this.preview.container,netgis.Events.IMPORT_LAYER_ACCEPT,a);this.preview.hide();this.modal.hide()};
netgis.Import.prototype.onPreviewTreeItemChange=function(a){a=a.detail;var b=this.previewMap.getLayers().getArray()[1].getSource().getFeatureById(a.id);a.checked?b.setStyle(null):b.setStyle(new ol.style.Style({}))};netgis.Import.prototype.onGeoportalSearchChange=function(a){a=this.geoportalSearch.value;a=a.trim();var b=this.config["import"].geoportal_search_url;b=netgis.util.replace(b,"{query}",a);console.info("Geoportal Search:",b);netgis.util.request(b,this.onGeoportalSearchResponse.bind(this))};
netgis.Import.prototype.onGeoportalSearchResponse=function(a){function b(a){if(a&&a.layer)for(var c=0;c<a.layer.length;c++)b(a.layer[c]);else a&&e.push(a);return e.length}a=JSON.parse(a);this.geoportalResults.clear();console.info("Geoportal Response:",a);this.geoportalDataRaw=a=a.wms.srv;this.geoportalData=[];for(var c=0;c<a.length;c++){var d=a[c];console.info("Result Layer:",d);var e=[];var f=b(d);f=this.geoportalResults.addFolder(null,c,d.title+" ("+f+")");f.setAttribute("title",d["abstract"]);
for(var g=0;g<e.length;g++){var h=e[g];console.info("Result Child:",h);this.geoportalResults.addCheckbox(f,g,h.title)}d.children=e;this.geoportalData.push(d)}};
netgis.Import.prototype.onGeoportalSubmit=function(a){console.info("Geoportal Submit...");a=this.geoportalResults.container.getElementsByClassName("netgis-item");for(var b=0,c=0;c<a.length;c++){var d=a[c],e=d.getElementsByTagName("input")[0];if(e.checked){b+=1;e=e.getAttribute("data-id");d=d.parentNode.parentNode.parentNode.getAttribute("data-id");var f=this.geoportalData[d],g=f.children[e];console.info("Item:",d,e,f,g);var h=f.title;f=f.getMapUrl;var k=g.name;g=g.title;d="geoportal_"+d;e=d+"_"+e;
netgis.util.invoke(this.sections.geoportal,netgis.Events.IMPORT_GEOPORTAL_SUBMIT,{folder:{id:d,title:h},layer:{id:e,url:f,name:k,title:g}})}}0<b&&this.modal.hide()};netgis=netgis||{};netgis.Info=function(a){this.config=a;this.queryLayers={};this.popup=new netgis.Popup;this.popup.setHeader("Abfrage:");this.initConfig(a)};netgis.Info.prototype.initConfig=function(a){for(a=a.layers.length-1;0<=a;a--);};netgis.Info.prototype.attachTo=function(a){this.popup.attachTo(a);a.addEventListener(netgis.Events.MAP_CLICK,this.onMapClick.bind(this));a.addEventListener(netgis.Events.MAP_LAYER_TOGGLE,this.onMapLayerToggle.bind(this))};netgis.Info.prototype.onContextResponse=function(a){this.initConfig(a.detail.context.config)};
netgis.Info.prototype.onMapLayerToggle=function(a){var b=a.detail;a=b.id;if(b.on){b=this.config.layers;for(var c=null,d=0;d<b.length;d++)if(b[d].id===a){c=b[d];break}if(c)switch(c.type){case netgis.LayerTypes.WMS:case netgis.LayerTypes.WMST:this.queryLayers[a]=c}}else delete this.queryLayers[a]};
netgis.Info.prototype.onMapClick=function(a){a=a.detail;if(a.mode===netgis.Modes.VIEW){this.popup.container!==a.overlay&&this.popup.attachTo(a.overlay);this.popup.clearContent();var b=0,c;for(c in this.queryLayers){var d=this.queryLayers[c];switch(d.type){case netgis.LayerTypes.WMS:case netgis.LayerTypes.WMST:var e=d.url;d.query_url&&(e=d.query_url);var f=["service=WMS","version=1.1.0","request=GetFeatureInfo","styles=","layers="+window.encodeURIComponent(d.name),"query_layers="+window.encodeURIComponent(d.name),
"bbox="+a.view.bbox.join(","),"srs="+a.view.projection,"width="+a.view.width,"height="+a.view.height,"x="+a.pixel[0],"y="+a.pixel[1],"info_format=text/html"];e=e+(-1===e.indexOf("?")?"?":"")+f.join("&");console.info("WMS REQUEST 1:",e);netgis.util.request(e,this.onLayerResponseWMS.bind(this),{title:d.title});b+=1}(e=d.query_url)&&""!==e&&(e=netgis.util.replace(e,"{bbox}",a.view.bbox.join(",")),e=netgis.util.replace(e,"{proj}",a.view.projection),e=netgis.util.replace(e,"{width}",a.view.width),e=netgis.util.replace(e,
"{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.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()};
netgis.LayerTree.prototype.onToolboxToggle=function(a){this.panel.hide()};netgis.LayerTree.prototype.onSearchParcelToggle=function(a){this.panel.hide()};netgis.LayerTree.prototype.onTreeButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.Client.handleCommand(a,b)};netgis.LayerTree.prototype.onMapLayerToggle=function(a){a=a.detail;this.tree.setItemChecked(a.id,a.on,!0);this.tree.updateFolderChecks()};
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.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))};
netgis.Logic.prototype.onSearchPlaceResponse=function(a){a=JSON.parse(a).data;this.modules.searchplace.search.clearResults();for(var b=0;b<a.length;b++){var c=a[b],d=c.name;c={type:"street",id:c.strid,lon:Number.parseFloat(c.wgs_x),lat:Number.parseFloat(c.wgs_y)};this.modules.searchplace.search.addResult(d,JSON.stringify(c))}};
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.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)}};
netgis.Map.prototype.initOverlays=function(){var a=document.createElement("div");a.className="netgis-map-overlay";this.popupOverlay=new ol.Overlay({id:"popup",element:a,positioning:"center-center"});this.map.addOverlay(this.popupOverlay)};
netgis.Map.prototype.initInteractions=function(){this.interactions[netgis.Modes.VIEW]=[new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.ZOOM_BOX]=[new ol.interaction.DragZoom({condition:function(a){return 0===a.originalEvent.button},out:!1}),new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.MEASURE_LINE]=
[new ol.interaction.DragPan,new ol.interaction.Modify({source:this.measureLayer.getSource(),deleteCondition:ol.events.condition.doubleClick,style:this.styleMeasure.bind(this)}),new ol.interaction.Draw({type:"LineString",source:this.measureLayer.getSource(),style:this.styleMeasure.bind(this)}),new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.PinchZoom,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.MEASURE_AREA]=[new ol.interaction.DragPan,
new ol.interaction.Modify({source:this.measureLayer.getSource(),deleteCondition:ol.events.condition.doubleClick,style:this.styleMeasure.bind(this)}),new ol.interaction.Draw({type:"Polygon",source:this.measureLayer.getSource(),style:this.styleMeasure.bind(this)}),new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.PinchZoom,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.MEASURE_LINE][2].on("drawstart",this.onMeasureLineBegin.bind(this));
this.interactions[netgis.Modes.MEASURE_AREA][2].on("drawstart",this.onMeasureAreaBegin.bind(this));if(!0===this.config.tools.editable){var a=this.config.tools.bounds?!0:!1;this.interactions[netgis.Modes.DRAW_POINTS]=[new ol.interaction.Draw({type:"Point",source:this.editLayer.getSource(),style:this.styleSketch.bind(this),geometryFunction:a?this.onDrawPointsUpdateGeom.bind(this):void 0}),new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),
new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_POINTS][0].on("drawend",this.onDrawBufferEnd.bind(this));if(a)this.interactions[netgis.Modes.DRAW_POINTS][0].on("drawend",this.onDrawPointsEnd.bind(this));this.interactions[netgis.Modes.DRAW_LINES]=[new ol.interaction.Draw({type:"LineString",source:this.editLayer.getSource(),style:this.styleSketch.bind(this),geometryFunction:a?this.onDrawLinesUpdateGeom.bind(this):void 0}),new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===
a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_LINES][0].on("drawend",this.onDrawBufferEnd.bind(this));if(a)this.interactions[netgis.Modes.DRAW_LINES][0].on("drawend",this.onDrawLinesEnd.bind(this));this.interactions[netgis.Modes.DRAW_POLYGONS]=[new ol.interaction.Draw({type:"Polygon",source:this.editLayer.getSource(),style:this.styleSketch.bind(this),geometryFunction:a?this.onDrawPolygonsUpdateGeom.bind(this):void 0}),new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===
a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];if(a)this.interactions[netgis.Modes.DRAW_POLYGONS][0].on("drawend",this.onDrawPolygonsEnd.bind(this));this.interactions[netgis.Modes.MODIFY_FEATURES]=[new ol.interaction.DragPan,new ol.interaction.Modify({source:this.editLayer.getSource(),deleteCondition:ol.events.condition.doubleClick,style:this.styleModify.bind(this)}),new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];
this.interactions[netgis.Modes.DELETE_FEATURES]=[new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURES_DRAW]=[new ol.interaction.Draw({type:"Polygon",style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.DragPan({condition:function(a){return 1===a.originalEvent.button}}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURES_DRAW][0].on("drawend",
this.onCutFeaturesDrawEnd.bind(this))}};netgis.Map.prototype.initConfig=function(a){a.map.bbox&&this.zoomBBox(a.map.bbox);a.map.zoom&&this.view.setZoom(a.map.zoom);a=a.layers;for(var b=a.length-1;0<=b;b--){var c=a[b];!0===c.active&&this.addLayer(c.id,c)}};
netgis.Map.prototype.attachTo=function(a){a.appendChild(this.container);a.addEventListener(netgis.Events.CLIENT_CONTEXT_RESPONSE,this.onClientContextResponse.bind(this));a.addEventListener(netgis.Events.CLIENT_SET_MODE,this.onClientSetMode.bind(this));a.addEventListener(netgis.Events.PANEL_TOGGLE,this.onPanelToggle.bind(this));a.addEventListener(netgis.Events.PANEL_RESIZE,this.onPanelResize.bind(this));a.addEventListener(netgis.Events.MAP_EDIT_LAYER_LOADED,this.onEditLayerLoaded.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM,
this.onMapZoom.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM_HOME,this.onMapZoomHome.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM_LONLAT,this.onMapZoomLonLat.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM_SCALE,this.onMapZoomScale.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM_LAYER,this.onMapZoomLayer.bind(this));a.addEventListener(netgis.Events.MAP_ZOOM_LEVEL,this.onMapZoomLevel.bind(this));a.addEventListener(netgis.Events.MAP_LAYER_TOGGLE,this.onMapLayerToggle.bind(this));
a.addEventListener(netgis.Events.MAP_LAYER_TRANSPARENCY,this.onMapLayerTransparency.bind(this));a.addEventListener(netgis.Events.MAP_SNAP_TOGGLE,this.onMapSnapToggle.bind(this));a.addEventListener(netgis.Events.MAP_VIEW_PREV,this.onMapViewPrev.bind(this));a.addEventListener(netgis.Events.MAP_VIEW_NEXT,this.onMapViewNext.bind(this));a.addEventListener(netgis.Events.MEASURE_CLEAR,this.onMeasureClear.bind(this));a.addEventListener(netgis.Events.DRAW_BUFFER_TOGGLE,this.onDrawBufferToggle.bind(this));
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.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};
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.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,
!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]})));return[c,d]};netgis.Map.prototype.styleHover=function(a){a=this.config.styles.select;return new ol.style.Style({image:new ol.style.Circle({radius:a.radius,fill:new ol.style.Fill({color:a.stroke})}),fill:new ol.style.Fill({color:a.fill}),stroke:new ol.style.Stroke({color:a.stroke,width:a.width}),zIndex:1})};
netgis.Map.prototype.getGeometryPoints=function(a){var b=a.getGeometry();if(b instanceof ol.geom.LineString)return new ol.geom.MultiPoint(b.getCoordinates());if(b instanceof ol.geom.Polygon){a=[];b=b.getCoordinates();for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiPolygon){a=[];for(var f=b.getPolygons(),g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);
return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiLineString){a=[];f=b.getPolygons();for(g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}return b};netgis.Map.prototype.redrawVectorLayers=function(){this.map.getLayers().forEach(function(a,b,c){(a instanceof ol.layer.Vector||a instanceof ol.layer.VectorTile)&&a.setStyle(a.getStyle())})};
netgis.Map.prototype.setSnapping=function(a){var b=this.config.tools.snapping;a?(this.snap=new ol.interaction.Snap({features:this.snapFeatures,pixelTolerance:b.tolerance?b.tolerance:10}),this.map.addInteraction(this.snap),this.snapFeatures.changed()):this.snap&&(this.map.removeInteraction(this.snap),this.snap=null);this.drawSnapOn=a};netgis.Map.prototype.setDrawTrace=function(a){};netgis.Map.prototype.addSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.push(a[b])};
netgis.Map.prototype.removeSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.remove(a[b])};netgis.Map.prototype.setDrawBuffer=function(a,b,c){if(a){var d=this.createBufferFeature(new ol.geom.Point(this.view.getCenter()),b,c);this.previewLayer.getSource().addFeature(d);this.drawBufferRadius=b;this.drawBufferSegments=c}else this.previewLayer.getSource().clear();this.drawBufferOn=a};
netgis.Map.prototype.createLayerTMS=function(a,b,c,d){if(b&&c&&d){b=[];d="map"===d?this.config.map.scales:d;c="map"===c?this.config.map.extent:c;for(var e=0;e<d.length;e++)b.unshift(this.getResolutionFromScale(d[e]));c=new ol.source.TileImage({crossOrigin:null,projection:this.view.getProjection(),tileGrid:new ol.tilegrid.TileGrid({extent:c,origin:[c[0],c[1]],resolutions:b}),tileUrlFunction:function(b){if(null!==b){var c=a;c=netgis.util.replace(c,"{z}",b[0]);c=netgis.util.replace(c,"{x}",b[1]);c=netgis.util.replace(c,
"{y}",b[2]);return c=netgis.util.replace(c,"{-y}",-b[2]-1)}}});c=new ol.layer.Tile({source:c})}else c=new ol.layer.Tile({source:new ol.source.XYZ({url:a,crossOrigin:"anonymous"})});return c};
netgis.Map.prototype.createLayerWMS=function(a,b,c,d,e,f){a={url:a,params:{LAYERS:b,FORMAT:c?c:"image/png",TRANSPARENT:"true",VERSION:"1.1.1"},hidpi:!1};e&&f&&(a.imageLoadFunction=function(a,b){var c=new XMLHttpRequest;c.open("GET",b);c.setRequestHeader("Authorization","Basic "+window.btoa(e+":"+f));c.onload=function(){a.getImage().src=b};c.send()});d?(d=new ol.source.TileWMS(a),d=new ol.layer.Tile({source:d})):(d=new ol.source.ImageWMS(a),d=new ol.layer.Image({source:d}));return d};
netgis.Map.prototype.createLayerWMST=function(a,b,c,d,e,f){a={url:a,params:{LAYERS:b,FORMAT:c?c:"image/png",TRANSPARENT:"true",VERSION:"1.1.1"},hidpi:!1};e&&f&&(a.imageLoadFunction=function(a,b){var c=new XMLHttpRequest;c.open("GET",b);c.setRequestHeader("Authorization","Basic "+window.btoa(e+":"+f));c.onload=function(){a.getImage().src=b};c.send()});d?(d=new ol.source.TileWMS(a),d=new ol.layer.Tile({source:d})):(d=new ol.source.ImageWMS(a),d=new ol.layer.Image({source:d}));return d};
netgis.Map.prototype.createLayerWMTS=function(a){for(var b=[],c=this.client.config.map.scales,d=this.client.config.map.extent,e=0;e<c.length;e++)b.unshift(this.getResolutionFromScale(c[e]));b=new ol.source.TileImage({crossOrigin:null,projection:this.view.getProjection(),tileGrid:new ol.tilegrid.TileGrid({extent:d,origin:[d[0],d[1]],resolutions:b}),tileUrlFunction:function(b){if(null!==b){var c=a;c=netgis.util.replace(c,"{z}",b[0]);c=netgis.util.replace(c,"{x}",b[1]);c=netgis.util.replace(c,"{y}",
b[2]);return c=netgis.util.replace(c,"{-y}",-b[2])}}});return new ol.layer.Tile({source:b})};
netgis.Map.prototype.createLayerWMTS_01=function(a,b){for(var c=this.view.getProjection().getExtent(),d=ol.extent.getWidth(c)/256,e=Array(14),f=Array(14),g=0;14>g;++g)e[g]=d/Math.pow(2,g),f[g]=g;source=new ol.source.WMTS({url:a,params:{LAYER:b,FORMAT:"image/png",TRANSPARENT:"true",VERSION:"1.1.1"},layer:b,format:"image/jpeg",matrixSet:"UTM32",tileGrid:new ol.tilegrid.WMTS({origin:ol.extent.getTopLeft(c),resolutions:e,matrixIds:f})})};
netgis.Map.prototype.createLayerGeoJSON=function(a){if(netgis.util.isObject(a)){var b=new ol.format.GeoJSON,c=b.readProjection(a);a=b.readFeatures(a,{featureProjection:this.view.getProjection()});c=c.getCode();switch(c){case "EPSG:3857":case "EPSG:4326":case this.view.getProjection().getCode():break;default:console.warn("unsupported import projection '"+c+"'")}var d=new ol.layer.Vector({source:new ol.source.Vector({features:a})});return d}if(netgis.util.isString(a)){d=new ol.layer.Vector({source:new ol.source.Vector({features:[]})});
var e=this;netgis.util.request(a,function(a){a=JSON.parse(a);a=e.createLayerGeoJSON(a);d.getSource().addFeatures(a.getSource().getFeatures())});return d}};
netgis.Map.prototype.createLayerGML=function(a){console.warn("GML support is experimental!");var b=[];a=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("gml:featureMember");for(var c=0;c<a.length;c++){for(var d={},e=a[c].children[0],f=0;f<e.attributes.length;f++){var g=e.attributes[f];d[g.nodeName]=g.nodeValue}for(f=0;f<e.children.length;f++)if(g=e.children[f],"ogr:geometryProperty"!==g.nodeName){var h=g.nodeName.split(":");d[h[h.length-1]]=g.innerHTML}e=e.getElementsByTagName("ogr:geometryProperty")[0].children[0];
(f=e.getAttribute("srsName"))&&"EPSG:4326"!==f&&f!==this.projection&&console.warn("unsupported import projection:",f);switch(e.nodeName){case "gml:Polygon":d.geometry=this.gmlParsePolygon(e,f);break;case "gml:MultiPolygon":d.geometry=this.gmlParseMultiPolygon(e,f)}d=new ol.Feature(d);b.push(d)}return new ol.layer.Vector({source:new ol.source.Vector({features:b})})};
netgis.Map.prototype.gmlParsePolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:LinearRing");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:coordinates")[0].innerHTML;c.push(this.gmlParseCoordinates(e,b))}return new ol.geom.Polygon(c)};netgis.Map.prototype.gmlParseMultiPolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:polygonMember");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:Polygon")[0];c.push(this.gmlParsePolygon(e,b))}return new ol.geom.MultiPolygon(c)};
netgis.Map.prototype.gmlParseCoordinates=function(a,b){a=a.split(" ");for(var c=0;c<a.length;c++){a[c]=a[c].split(",");for(var d=0;d<a[c].length;d++)a[c][d]=Number.parseFloat(a[c][d]);b&&(a[c]=ol.proj.transform(a[c],b,this.view.getProjection()))}return a};
netgis.Map.prototype.createLayerGeoPackage=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;a=new Uint8Array(a);window.GeoPackage.setSqljsWasmLocateFile(function(a){return c.config["import"].geopackage_lib+a});window.GeoPackage.GeoPackageAPI.open(a).then(function(a){for(var d=[],f=new ol.format.GeoJSON,g=a.getFeatureTables(),h=0;h<g.length;h++)for(var k=a.queryForGeoJSONFeaturesInTable(g[h]),l=0;l<k.length;l++){var m=f.readGeometry(k[l].geometry,{featureProjection:c.view.getProjection()});
m=new ol.Feature({geometry:m});d.push(m)}b.getSource().addFeatures(d)});return b};
netgis.Map.prototype.createLayerSpatialite=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;window.initSqlJs().then(function(d){var e=[],f=new Uint8Array(a);d=new d.Database(f);var g=d.exec("SELECT name FROM sqlite_schema WHERE type = 'table' \n\t\t\t\t\tAND name NOT LIKE 'sqlite_%' \n\t\t\t\t\tAND name NOT LIKE 'sql_%' \n\t\t\t\t\tAND name NOT LIKE 'idx_%' \n\t\t\t\t\tAND name NOT LIKE 'spatial_ref_sys%' \n\t\t\t\t\tAND name NOT LIKE 'spatialite_%' \n\t\t\t\t\tAND name NOT LIKE 'geometry_columns%' \n\t\t\t\t\tAND name NOT LIKE 'views_%' \n\t\t\t\t\tAND name NOT LIKE 'virts_%' \n\t\t\t\t\tAND name NOT LIKE 'SpatialIndex' \n\t\t\t\t\tAND name NOT LIKE 'KNN%' \n\t\t\t\t\tAND name NOT LIKE 'ElementaryGeometries' \n\t\t\t\t;");f=
g[0].values;for(var h=0;h<f.length;h++){g=d.exec("SELECT * FROM "+f[h][0]);var k=g[0];g=null;for(var l=0;l<k.columns.length;l++){if("geometry"===k.columns[l].toLowerCase()){g=l;break}if("geom"===k.columns[l].toLowerCase()){g=l;break}}if(null!==g)for(k=k.values,l=0;l<k.length;l++){var m=k[l][g],n=new Uint8Array(m.length-43-1+5);n[0]=m[1];n[1]=m[39];n[2]=m[40];n[3]=m[41];n[4]=m[42];for(var q=m.length-43-1,p=0;p<q;p++)n[5+p]=m[43+p];m=(new ol.format.WKB).readGeometry(n,{featureProjection:c.view.getProjection()});
e.push(new ol.Feature({geometry:m}))}}b.getSource().addFeatures(e)});return b};netgis.Map.prototype.createLayerShapefile=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;shp(a).then(function(a){var d=new ol.format.GeoJSON;d.readProjection(a);a=d.readFeatures(a,{featureProjection:c.view.getProjection()});b.getSource().addFeatures(a)});return b};
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.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.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.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.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.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.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.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"),
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.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){};
netgis.Map.prototype.onImportLayerPreview=function(a){a=a.detail;var b=this.createLayer(a),c=this.view.getProjection().getCode();netgis.util.invoke(this.container,netgis.Events.IMPORT_LAYER_PREVIEW_FEATURES,{id:a.id,title:a.title,layer:b,proj:c})};netgis.Map.prototype.onSearchParcelReset=function(a){(a=this.config.searchparcel.districts_service.min_zoom)&&this.view.setZoom(a)};netgis.Map.prototype.onSearchParcelItemEnter=function(a){a=a.detail.id;this.layers.searchparcel_parcels.getSource().getFeatureById(a).setStyle(this.styleHover.bind(this))};
netgis.Map.prototype.onSearchParcelItemLeave=function(a){a=a.detail.id;this.layers.searchparcel_parcels.getSource().getFeatureById(a).setStyle(null)};netgis.Map.prototype.onSearchParcelItemClick=function(a){a=a.detail.id;console.info("PARCEL CLICK:",a);this.zoomFeature("searchparcel_parcels",a)};netgis.Map.prototype.onSearchParcelItemImport=function(a){};netgis.Map.prototype.onDrawPointsUpdateGeom=function(a,b,c){b?b.setCoordinates(a):b=new ol.geom.Point(a);return b};
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.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";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";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";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.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.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.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)};
netgis.Panel.prototype.attachTo=function(a){a.appendChild(this.container)};netgis.Panel.prototype.addHeader=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-clip-text netgis-color-c netgis-shadow";d.innerHTML="<span>"+b+"</span><i class='netgis-icon fas fa-times'></i>";d.setAttribute("type","button");c&&(d.onpointerdown=c);a&&a.appendChild(d);return d};
netgis.Panel.prototype.show=function(){this.container.classList.contains("netgis-show")||(this.container.classList.add("netgis-show"),netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{visible:!0,width:this.container.getBoundingClientRect().width}))};netgis.Panel.prototype.hide=function(){this.container.classList.contains("netgis-show")&&(this.container.classList.remove("netgis-show"),netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{visible:!1}))};
netgis.Panel.prototype.toggle=function(){this.container.classList.toggle("netgis-show");var a=this.container.classList.contains("netgis-show");netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{visible:a,width:a?this.container.getBoundingClientRect().width:void 0})};netgis.Panel.prototype.visible=function(){return this.container.classList.contains("netgis-show")};netgis.Panel.prototype.width=function(){return this.container.getBoundingClientRect().width};
netgis.Panel.prototype.setTitle=function(a){this.header.getElementsByTagName("span")[0].innerHTML=a};netgis.Panel.prototype.onHeaderClick=function(a){this.hide()};netgis.Panel.prototype.onResize=function(a){this.container.classList.contains("netgis-show")&&(a=this.container.getBoundingClientRect(),netgis.util.invoke(this.container,netgis.Events.PANEL_RESIZE,{width:a.width}))};netgis=netgis||{};netgis.Popup=function(){this.initElements()};
netgis.Popup.prototype.initElements=function(){document.body.addEventListener("pointerdown",this.onDocumentPointerDown.bind(this));this.container=document.createElement("div");this.container.className="netgis-popup";this.container.addEventListener("pointerdown",this.onPointerDown.bind(this));this.content=document.createElement("div");this.content.className="netgis-content netgis-color-e netgis-round";this.container.appendChild(this.content);this.arrow=document.createElement("div");this.arrow.className=
"netgis-arrow-down";this.container.appendChild(this.arrow);this.closer=document.createElement("button");this.closer.setAttribute("type","button");this.closer.className="netgis-closer netgis-color-e netgis-text-a";this.closer.innerHTML="<span></span><i class='fas fa-times'></i>";this.closer.onclick=this.onCloserClick.bind(this);this.content.appendChild(this.closer);this.loader=document.createElement("div");this.loader.className="netgis-loader netgis-text-a";this.loader.innerHTML="<i class='netgis-icon netgis-anim-spin fas fa-sync-alt'></i>";
this.wrapper=document.createElement("div");this.wrapper.className="netgis-wrapper";this.content.appendChild(this.wrapper)};netgis.Popup.prototype.attachTo=function(a){a.appendChild(this.container)};netgis.Popup.prototype.show=function(){this.container.classList.add("netgis-show")};netgis.Popup.prototype.hide=function(){this.container.classList.remove("netgis-show")};netgis.Popup.prototype.showLoader=function(){this.content.appendChild(this.loader)};
netgis.Popup.prototype.hideLoader=function(){this.loader.parentNode===this.content&&this.content.removeChild(this.loader)};
netgis.Popup.prototype.setPosition=function(a,b){var c=this.container.parentNode.getBoundingClientRect(),d=this.arrow.getBoundingClientRect();a>c.width-d.width&&(a=c.width-d.width);a<d.width&&(a=d.width);this.container.style.left=a+"px";this.container.style.top=b+"px";this.content.style.left="";a=this.content.getBoundingClientRect();0>a.x?this.content.style.left=-a.x+"px":a.x+a.width>c.width&&(this.content.style.left=-(a.x+a.width-c.width)+"px")};
netgis.Popup.prototype.setHeader=function(a){this.closer.getElementsByTagName("span")[0].innerHTML=a};netgis.Popup.prototype.setContent=function(a){this.wrapper.innerHTML=a};netgis.Popup.prototype.clearContent=function(){this.wrapper.innerHTML=""};netgis.Popup.prototype.addContent=function(a){this.wrapper.innerHTML+=a};netgis.Popup.prototype.onDocumentPointerDown=function(a){};netgis.Popup.prototype.onPointerDown=function(a){a.stopPropagation()};netgis.Popup.prototype.onCloserClick=function(a){this.hide()};netgis=netgis||{};netgis.Search=function(a){this.debounce=400;this.initElements(a);this.initEvents()};
netgis.Search.prototype.initElements=function(a){var b=document.createElement("div");b.className="netgis-search";this.container=b;var c=document.createElement("label");b.appendChild(c);this.label=c;var d=document.createElement("input");d.className="netgis-round netgis-shadow";d.setAttribute("type","text");d.setAttribute("placeholder",a);c.appendChild(d);this.input=d;a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="<i class='fas fa-search'></i>";c.appendChild(a);this.button=
a;a=document.createElement("button");a.setAttribute("type","button");a.className="netgis-hide";a.innerHTML="<i class='fas fa-times'></i>";c.appendChild(a);this.closer=a;c=document.createElement("ul");b.appendChild(c);this.results=c};
netgis.Search.prototype.initEvents=function(){this.input.addEventListener("change",this.onInputChange.bind(this));this.input.addEventListener("keydown",this.onInputKeyDown.bind(this));this.input.addEventListener("keyup",this.onInputKeyUp.bind(this));this.button.addEventListener("click",this.onButtonClick.bind(this));this.closer.addEventListener("click",this.onCloserClick.bind(this))};netgis.Search.prototype.attachTo=function(a){a.appendChild(this.container)};netgis.Search.prototype.show=function(){this.container.classList.remove("netgis-hide")};
netgis.Search.prototype.hide=function(){this.container.classList.add("netgis-hide")};netgis.Search.prototype.toggle=function(){this.container.classList.toggle("netgis-hide")};netgis.Search.prototype.isVisible=function(){return!this.container.classList.contains("netgis-hide")};netgis.Search.prototype.minimize=function(){this.container.classList.remove("netgis-color-e","netgis-shadow");this.input.classList.add("netgis-shadow")};
netgis.Search.prototype.maximize=function(){this.container.classList.add("netgis-color-e","netgis-shadow");this.input.classList.remove("netgis-shadow")};netgis.Search.prototype.setTitle=function(a){this.input.setAttribute("placeholder",a)};
netgis.Search.prototype.addResult=function(a,b){var c=document.createElement("li"),d=document.createElement("button");d.className="netgis-button netgis-clip-text netgis-color-e netgis-hover-a";d.innerHTML=a;d.setAttribute("type","button");d.setAttribute("title",d.innerText);d.setAttribute("data-result",b);d.addEventListener("click",this.onResultClick.bind(this));c.appendChild(d);0===this.results.childNodes.length&&(this.button.classList.add("netgis-hide"),this.closer.classList.remove("netgis-hide"));
this.results.appendChild(c);this.maximize();return c};netgis.Search.prototype.clearResults=function(){this.results.innerHTML="";this.minimize();netgis.util.invoke(this.container,netgis.Events.SEARCH_CLEAR,null)};netgis.Search.prototype.clearAll=function(){this.clearResults();this.lastQuery=null;this.input.value="";this.button.classList.remove("netgis-hide");this.closer.classList.add("netgis-hide")};
netgis.Search.prototype.requestSearch=function(a){this.lastQuery&&this.lastQuery===a||(this.lastQuery=a,netgis.util.invoke(this.container,netgis.Events.SEARCH_CHANGE,{query:a}))};netgis.Search.prototype.onInputKeyDown=function(a){if(13===a.keyCode)return a.preventDefault(),!1};netgis.Search.prototype.onInputKeyUp=function(a){switch(a.keyCode){case 13:a=this.results.getElementsByTagName("button");0<a.length&&a[0].click();break;case 27:this.clearAll();break;default:this.onInputChange()}};
netgis.Search.prototype.onInputChange=function(a){this.timeout&&window.clearTimeout(this.timeout);this.timeout=window.setTimeout(this.onInputTimeout.bind(this),this.debounce)};netgis.Search.prototype.onInputTimeout=function(){var a=this.input.value;a=a.trim();0<a.length?this.requestSearch(a):this.clearAll()};netgis.Search.prototype.onButtonClick=function(a){this.input.focus()};netgis.Search.prototype.onCloserClick=function(a){this.clearAll();this.input.focus()};
netgis.Search.prototype.onResultClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-result");netgis.util.invoke(a,netgis.Events.SEARCH_SELECT,{item:a,data:b})};netgis=netgis||{};netgis.SearchParcel=function(a){this.config=a;this.districtsLayerID="searchparcel_districts";this.fieldsLayerID="searchparcel_fields";this.parcelsLayerID="searchparcel_parcels";this.parcelsAdded=[];this.initElements();this.initEvents();this.initConfig(a)};
netgis.SearchParcel.prototype.initElements=function(){this.panel=new netgis.Panel("Flurst\u00fccks-Suche");this.panel.container.style.minWidth="92mm";this.panel.container.addEventListener(netgis.Events.PANEL_TOGGLE,this.onPanelToggle.bind(this));this.container=document.createElement("section");this.container.className="netgis-search-parcel";this.panel.content.appendChild(this.container);var a=document.createElement("section");this.top=a;this.container.appendChild(a);var b=this.createInput("Gemarkungsname:");
b.style.position="relative";a.appendChild(b);this.nameInput=b.children[0];this.nameInput.setAttribute("title","ENTER: Ausw\u00e4hlen, ESCAPE: Zur\u00fccksetzen");this.nameInput.addEventListener("keyup",this.onInputNameKey.bind(this));this.nameLoader=document.createElement("div");this.nameLoader.className="netgis-loader netgis-text-primary netgis-hide";this.nameLoader.innerHTML="<i class='fas fa-spinner'></i>";b.appendChild(this.nameLoader);this.nameList=document.createElement("ul");a.appendChild(this.nameList);
b=this.createInput("Gemarkungsnummer:");this.districtInput=b.children[0];a.appendChild(b);b=this.createInput("Flurnummer:");this.fieldInput=b.children[0];this.fieldInput.addEventListener("keyup",this.onInputFieldKey.bind(this));a.appendChild(b);b=this.createInput("<span>Flurst\u00fccksnummer (Z\u00e4hler/Nenner):</span>");this.parcelInputA=b.children[1];this.parcelInputA.style.width="48%";this.parcelInputB=this.parcelInputA.cloneNode(!0);this.parcelInputB.style.marginLeft="4%";b.appendChild(this.parcelInputB);
a.appendChild(b);b=document.createElement("button");b.setAttribute("type","button");b.addEventListener("click",this.onParcelSearchClick.bind(this));b.className="netgis-color-a netgis-hover-c";b.innerHTML="Flurst\u00fccke suchen";b.style.marginTop="4mm";a.appendChild(b);b=document.createElement("section");b.className="netgis-hide";this.bottom=b;this.container.appendChild(b);var c=document.createElement("button");c.className="netgis-button netgis-clip-text netgis-color-c";c.innerHTML="<span>Flurst\u00fccke</span> <span></span><i class='netgis-icon fas fa-times'></i>";
c.setAttribute("type","button");c.addEventListener("click",this.onBottomHeaderClick.bind(this));b.appendChild(c);this.parcelCount=c.getElementsByTagName("span")[1];this.parcelInfo=document.createElement("p");this.parcelTable=this.createTable(";Flur;Z\u00e4hler;Nenner;FKZ;Fl\u00e4che (qm)".split(";"));this.parcelTable.classList.add("netgis-hide");this.parcelTable.style.position="absolute";this.parcelTable.style.width="100%";this.parcelTable.style.top="12mm";this.parcelTable.style.bottom="0mm";this.parcelTable.style.margin=
"0mm";this.parcelTable.style.overflow="auto";b.appendChild(this.parcelTable);this.parcelList=this.parcelTable.getElementsByTagName("tbody")[0];this.parcelReset=document.createElement("button");this.parcelReset.setAttribute("type","button");this.parcelReset.addEventListener("click",this.onResetClick.bind(this));this.parcelReset.className="netgis-color-a netgis-hover-c";this.parcelReset.innerHTML="Zur\u00fccksetzen";this.parcelReset.style.marginTop="4mm";a.appendChild(this.parcelReset)};
netgis.SearchParcel.prototype.initEvents=function(){this.resizeObserver=(new ResizeObserver(this.onTopResize.bind(this))).observe(this.top)};
netgis.SearchParcel.prototype.initConfig=function(a){this.districtsLayer=a.searchparcel.districts_service;this.districtsLayer.id=this.districtsLayerID;this.districtsLayer.style=a.styles.parcel;this.districtsLayer.order=99999;a.layers.push(this.districtsLayer);this.fieldsLayer={id:this.fieldsLayerID,type:netgis.LayerTypes.GEOJSON,style:a.styles.parcel,order:99999,data:null};a.layers.push(this.fieldsLayer);this.parcelsLayer={id:this.parcelsLayerID,type:netgis.LayerTypes.WKT,style:a.styles.parcel,order:99999,
data:null};a.layers.push(this.parcelsLayer);if(!0===a.searchparcel.open){var b=this;window.setTimeout(function(){b.panel.show()},100)}};
netgis.SearchParcel.prototype.attachTo=function(a){this.panel.attachTo(a);a.addEventListener(netgis.Events.CLIENT_SET_MODE,this.onClientSetMode.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_TOGGLE,this.onSearchParcelToggle.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.MAP_FEATURE_ENTER,this.onMapFeatureEnter.bind(this));a.addEventListener(netgis.Events.MAP_FEATURE_CLICK,
this.onMapFeatureClick.bind(this));a.addEventListener(netgis.Events.MAP_FEATURE_LEAVE,this.onMapFeatureLeave.bind(this))};netgis.SearchParcel.prototype.createInput=function(a){var b=document.createElement("label");b.className="netgis-hover-text-primary";b.innerHTML=a;a=document.createElement("input");a.setAttribute("type","text");b.appendChild(a);return b};
netgis.SearchParcel.prototype.createNameItem=function(a){var b=document.createElement("li"),c=document.createElement("button");c.setAttribute("type","button");c.addEventListener("click",this.onNameItemClick.bind(this));c.className="netgis-color-e netgis-hover-a netgis-text-a netgis-hover-text-e";c.innerHTML=a;b.appendChild(c);return b};
netgis.SearchParcel.prototype.createTable=function(a){var b=document.createElement("div");b.className="netgis-table-wrapper";var c=document.createElement("table");b.appendChild(c);var d=document.createElement("thead");c.appendChild(d);var e=document.createElement("tr");e.className="netgis-color-d netgis-shadow";d.appendChild(e);for(d=0;d<a.length;d++){var f=document.createElement("th");f.innerHTML=a[d];e.appendChild(f)}a=document.createElement("tbody");c.appendChild(a);return b};
netgis.SearchParcel.prototype.createParcelItem=function(a,b,c,d,e,f,g){var h=document.createElement("tr");h.className="netgis-hover-d";h.setAttribute("title","Klicken zum zoomen");h.setAttribute("data-id",d);h.setAttribute("data-field",a);h.setAttribute("data-parcel-a",b);h.setAttribute("data-parcel-b",c);h.setAttribute("data-bbox",f);h.setAttribute("data-geom",g);h.addEventListener("pointerenter",this.onParcelEnter.bind(this));h.addEventListener("pointerleave",this.onParcelLeave.bind(this));h.addEventListener("click",
this.onParcelClick.bind(this));f=document.createElement("td");h.appendChild(f);g=document.createElement("button");g.setAttribute("type","button");g.setAttribute("title","Geometrie \u00fcbernehmen");g.addEventListener("click",this.onParcelImportClick.bind(this));g.className="netgis-hover-a";g.innerHTML="<i class='fas fa-paste'></i>";f.appendChild(g);f=document.createElement("td");f.innerHTML=a;h.appendChild(f);a=document.createElement("td");a.innerHTML=b;h.appendChild(a);b=document.createElement("td");
b.innerHTML=c;h.appendChild(b);c=document.createElement("td");c.innerHTML=netgis.util.trim(d,"_");h.appendChild(c);d=document.createElement("td");d.innerHTML=e;h.appendChild(d);return h};
netgis.SearchParcel.prototype.reset=function(){this.hideBottom();this.nameLoader.classList.add("netgis-hide");this.nameInput.value="";this.districtInput.value="";this.fieldInput.value="";this.parcelInputA.value="";this.parcelInputB.value="";this.nameList.innerHTML="";this.parcelInfo.innerHTML="";this.parcelList.innerHTML="";this.parcelTable.classList.add("netgis-hide");this.parcelReset.classList.add("netgis-hide");this.parcelCount.innerHTML="";var a=this;window.setTimeout(function(){a.top.scrollTop=
0;a.parcelTable.scrollTop=0},10);netgis.util.invoke(this.container,netgis.Events.SEARCHPARCEL_RESET,null);this.panel.visible()&&this.showDistricts(!0);this.showFields(!1);this.showParcels(!1)};
netgis.SearchParcel.prototype.showDistricts=function(a){a?(netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:this.districtsLayerID,on:!0}),netgis.util.invoke(this.container,netgis.Events.MAP_ZOOM_LEVEL,{z:this.config.searchparcel.districts_service.min_zoom})):netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:this.districtsLayerID,on:!1})};
netgis.SearchParcel.prototype.showFields=function(a,b){a?(b.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::25832"}},this.fieldsLayer.data=b,netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:this.fieldsLayerID,on:!0}),netgis.util.invoke(this.container,netgis.Events.MAP_ZOOM_LAYER,{id:this.fieldsLayerID})):(netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:this.fieldsLayerID,on:!1}),this.fieldsLayer.data=null)};
netgis.SearchParcel.prototype.showParcels=function(a,b){if(a){a=[];for(var c=0;c<b.length;c++){var d=b[c];a.push({id:d.fsk,geometry:d.geometry,properties:{flaeche:d.flaeche,fln:d.fln,fsk:d.fsk,fsn_nen:d.fsn_nen,fsn_zae:d.fsn_zae}})}this.parcelsLayer.data=a;netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,{id:this.parcelsLayerID,on:!0});netgis.util.invoke(this.container,netgis.Events.MAP_ZOOM_LAYER,{id:this.parcelsLayerID})}else netgis.util.invoke(this.container,netgis.Events.MAP_LAYER_TOGGLE,
{id:this.parcelsLayerID,on:!1})};netgis.SearchParcel.prototype.onSearchParcelToggle=function(a){this.panel.toggle()};netgis.SearchParcel.prototype.onLayerTreeToggle=function(a){this.panel.hide()};netgis.SearchParcel.prototype.onToolboxToggle=function(a){this.panel.hide()};netgis.SearchParcel.prototype.onClientSetMode=function(a){a.detail.mode===netgis.Modes.SEARCH_PARCEL?this.reset():(this.showDistricts(!1),this.showFields(!1),this.showParcels(!1))};
netgis.SearchParcel.prototype.onPanelToggle=function(a){!1===a.detail.visible?netgis.util.invoke(this.panel.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW}):netgis.util.invoke(this.panel.container,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.SEARCH_PARCEL})};netgis.SearchParcel.prototype.onInputNameKey=function(a){switch(a.keyCode){case 13:this.selectFirstName();break;case 27:this.reset();break;default:this.requestName(this.nameInput.value.trim())}};
netgis.SearchParcel.prototype.requestName=function(a){this.nameDebounce&&window.clearTimeout(this.nameDebounce);if(0!==a.length){var b=this.config.searchparcel.name_url;b=netgis.util.replace(b,"{q}",window.encodeURIComponent(a));this.nameDebounce=window.setTimeout(this.onInputNameDebounce.bind(this,b),200);this.nameLoader.classList.remove("netgis-hide")}};netgis.SearchParcel.prototype.onInputNameDebounce=function(a){netgis.util.request(a,this.onInputNameResponse.bind(this))};
netgis.SearchParcel.prototype.onInputNameResponse=function(a){this.nameLoader.classList.add("netgis-hide");this.parcelReset.classList.remove("netgis-hide");this.nameList.innerHTML="";if("{"===a.charAt(0)||"["===a.charAt(0)){a=JSON.parse(a);for(var b=0;b<a.data.length;b++){var c=a.data[b],d=this.createNameItem(c.gmk_name);d.getElementsByTagName("button")[0].setAttribute("data-id",c.gmk_gmn);this.nameList.appendChild(d)}}};
netgis.SearchParcel.prototype.onNameItemClick=function(a){a=a.target;var b=a.getAttribute("data-id");this.nameInput.value=a.innerHTML;this.nameList.innerHTML="";this.districtInput.value=b;this.requestFields(b)};
netgis.SearchParcel.prototype.requestFields=function(a){var b=this.config.searchparcel.fields_service,c=b.url;c=c+"service=WFS&version=1.0.0&request=GetFeature&outputFormat=application/json; subtype=geojson&typename="+b.name;c=c+"&filter=<Filter><PropertyIsEqualTo><PropertyName>"+(b.filter_property+"</PropertyName>");netgis.util.request(c+("<Literal>"+a+"</Literal></PropertyIsEqualTo></Filter>"),this.onFieldsResponse.bind(this))};
netgis.SearchParcel.prototype.onFieldsResponse=function(a){a=JSON.parse(a);this.showDistricts(!1);this.showFields(!0,a);this.showParcels(!1)};netgis.SearchParcel.prototype.selectFirstName=function(){var a=this.nameList.getElementsByTagName("button");0<a.length&&a[0].click()};netgis.SearchParcel.prototype.setDistrict=function(a,b){this.nameInput.value=a;this.districtInput.value=b;this.requestFields(b)};netgis.SearchParcel.prototype.setFieldNumber=function(a){this.fieldInput.value=a;this.onParcelSearchClick()};
netgis.SearchParcel.prototype.setParcelNumber=function(a,b){this.parcelInputA.value=a;this.parcelInputB.value=b;this.onParcelSearchClick()};netgis.SearchParcel.prototype.showBottom=function(){this.top.classList.add("netgis-resize-bottom");this.top.style.height="50%";this.top.style.bottom="auto";this.bottom.classList.remove("netgis-hide")};netgis.SearchParcel.prototype.hideBottom=function(){this.top.classList.remove("netgis-resize-bottom");this.top.style.height="auto";this.top.style.bottom="0mm";this.bottom.classList.add("netgis-hide")};
netgis.SearchParcel.prototype.onInputFieldKey=function(a){switch(a.keyCode){case 13:this.onParcelSearchClick()}};netgis.SearchParcel.prototype.onParcelSearchClick=function(a){this.requestParcels(this.districtInput.value.trim(),this.fieldInput.value.trim(),this.parcelInputA.value.trim(),this.parcelInputB.value.trim())};
netgis.SearchParcel.prototype.requestParcels=function(a,b,c,d){var e=this.config.searchparcel.parcel_url;e=netgis.util.replace(e,"{district}",a?a:"");e=netgis.util.replace(e,"{field}",b?b:"");e=netgis.util.replace(e,"{parcelA}",c?c:"");e=netgis.util.replace(e,"{parcelB}",d?d:"");this.parcelTable.classList.add("netgis-hide");this.parcelList.innerHTML="";this.parcelInfo.innerHTML="Suche Flurst\u00fccke...";netgis.util.request(e,this.onParcelsResponse.bind(this))};
netgis.SearchParcel.prototype.onParcelsResponse=function(a){a=JSON.parse(a);this.parcelCount.innerHTML="("+a.count+")";if(0===a.count)this.parcelInfo.innerHTML=a.Info;else{for(var b=0;b<a.data.length;b++){var c=a.data[b];c=this.createParcelItem(c.fln,c.fsn_zae,c.fsn_nen,c.fsk,c.flaeche,c.bbox,c.geometry);this.parcelList.appendChild(c)}this.parcelTable.classList.remove("netgis-hide");this.showBottom();this.showDistricts(!1);this.showFields(!1);this.showParcels(!0,a.data)}this.container.classList.contains("netgis-hide")||
this.parcelTable.scrollIntoView()};netgis.SearchParcel.prototype.onParcelEnter=function(a){a=a.target;var b=a.getAttribute("data-geom");a={id:a.getAttribute("data-id"),field:a.getAttribute("data-field"),parcelA:a.getAttribute("data-parcel-a"),parcelB:a.getAttribute("data-parcel-b"),geom:b};netgis.util.invoke(this.container,netgis.Events.SEARCHPARCEL_ITEM_ENTER,a)};netgis.SearchParcel.prototype.onParcelLeave=function(a){netgis.util.invoke(this.container,netgis.Events.SEARCHPARCEL_ITEM_LEAVE,{id:a.target.getAttribute("data-id")})};
netgis.SearchParcel.prototype.onParcelClick=function(a){netgis.util.invoke(this.container,netgis.Events.SEARCHPARCEL_ITEM_CLICK,{id:a.currentTarget.getAttribute("data-id")})};netgis.SearchParcel.prototype.onParcelImportClick=function(a){a.stopPropagation();a=a.currentTarget.parentElement.parentElement;var b=a.getAttribute("data-id");a.getAttribute("data-geom");netgis.util.invoke(this.container,netgis.Events.MAP_COPY_FEATURE_TO_EDIT,{source:this.parcelsLayerID,id:b})};
netgis.SearchParcel.prototype.onResetClick=function(a){this.reset()};netgis.SearchParcel.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.SearchParcel.prototype.onBottomHeaderClick=function(a){this.reset()};
netgis.SearchParcel.prototype.onMapFeatureEnter=function(a){var b=a.target;a=a.detail;switch(a.layer){case this.districtsLayerID:var c=a.properties.gemarkung;b.setAttribute("title",c);break;case this.fieldsLayerID:c=a.properties.flurname;b.setAttribute("title",c);break;case this.parcelsLayerID:for(c="Flur: "+a.properties.fln+" / Z\u00e4hler: "+a.properties.fsn_zae+" / Nenner: "+a.properties.fsn_nen,b.setAttribute("title",c),b=a.properties.fsk,a=this.parcelList.getElementsByTagName("tr"),c=0;c<a.length;c++){var d=
a[c];if(d.getAttribute("data-id")===b){d.scrollIntoView({behavior:"smooth",block:"center"});d.classList.add("netgis-color-d");break}}}};
netgis.SearchParcel.prototype.onMapFeatureClick=function(a){a=a.detail;switch(a.layer){case this.districtsLayerID:this.setDistrict(a.properties.gemarkung+" ("+a.properties.ldkreis+")",a.properties.gmkgnr);break;case this.fieldsLayerID:this.setFieldNumber(a.properties.flur);break;case this.parcelsLayerID:netgis.util.invoke(this.container,netgis.Events.MAP_COPY_FEATURE_TO_EDIT,{source:this.parcelsLayerID,id:a.properties.fsk})}};
netgis.SearchParcel.prototype.onMapFeatureLeave=function(a){var b=a.target;a=a.detail;switch(a.layer){case this.districtsLayerID:case this.fieldsLayerID:b.setAttribute("title","");break;case this.parcelsLayerID:b.setAttribute("title","");b=a.properties.fsk;a=this.parcelList.getElementsByTagName("tr");for(var c=0;c<a.length;c++){var d=a[c];if(d.getAttribute("data-id")===b){d.classList.remove("netgis-color-d");break}}}};netgis=netgis||{};netgis.SearchPlace=function(a){this.config=a;this.initElements();this.initEvents();this.initConfig(a)};
netgis.SearchPlace.prototype.initElements=function(){this.search=new netgis.Search("");this.container=this.search.container;this.container.classList.add("netgis-search-place","netgis-responsive");this.search.container.addEventListener(netgis.Events.SEARCH_CHANGE,this.onSearchChange.bind(this));this.search.container.addEventListener(netgis.Events.SEARCH_SELECT,this.onSearchSelect.bind(this));this.search.container.addEventListener(netgis.Events.SEARCH_CLEAR,this.onSearchClear.bind(this))};
netgis.SearchPlace.prototype.initEvents=function(){};netgis.SearchPlace.prototype.initConfig=function(a){this.search.setTitle(a.searchplace.title)};netgis.SearchPlace.prototype.attachTo=function(a){this.search.attachTo(a);a.addEventListener(netgis.Events.SEARCHPLACE_TOGGLE,this.onSearchPlaceToggle.bind(this))};netgis.SearchPlace.prototype.onSearchPlaceToggle=function(a){this.search.toggle()};
netgis.SearchPlace.prototype.onSearchChange=function(a){var b=this.config.searchplace.url;b=netgis.util.replace(b,"{query}",window.encodeURIComponent(a.detail.query));b=netgis.util.replace(b,"{epsg}",4326);netgis.util.request(b,this.onSearchResponse.bind(this))};
netgis.SearchPlace.prototype.onSearchResponse=function(a){a=JSON.parse(a);this.search.clearResults();if(a.geonames){a=a.geonames;for(var b=0;b<a.length;b++){var c=a[b],d=c.title,e=.5*(Number.parseFloat(c.minx)+Number.parseFloat(c.maxx)),f=.5*(Number.parseFloat(c.miny)+Number.parseFloat(c.maxy));c={type:c.category,id:b,lon:e,lat:f};this.search.addResult(d,JSON.stringify(c))}}else if(a.data)for(a=a.data,b=0;b<a.length;b++)c=a[b],d=c.name,c={type:"street",id:c.strid,lon:Number.parseFloat(c.wgs_x),lat:Number.parseFloat(c.wgs_y)},
this.search.addResult(d,JSON.stringify(c))};netgis.SearchPlace.prototype.onSearchSelect=function(a){a=JSON.parse(a.detail.data);netgis.util.invoke(this.container,netgis.Events.MAP_ZOOM_LONLAT,{lon:a.lon,lat:a.lat,zoom: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.onSearchDetailResponse.bind(this)))}};
netgis.SearchPlace.prototype.onSearchDetailResponse=function(a){a=JSON.parse(a);var b=a.hsnrarr;if(0!==b.length){this.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.search.addResult(e,JSON.stringify(d))}}};netgis.SearchPlace.prototype.onSearchClear=function(a){};netgis=netgis||{};
netgis.SLD=function(){return{read:function(a,b){var c={};a=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("NamedLayer");for(var d=0;d<a.length;d++){var e=a[d],f=e.getElementsByTagName("se:Name")[0].innerHTML;console.info("Layer:",f);e=e.getElementsByTagName("se:FeatureTypeStyle");for(f=0;f<e.length;f++)for(var g=e[f].getElementsByTagName("se:Rule"),h=0;h<g.length;h++){var k=g[h],l=k.getElementsByTagName("se:Name")[0].innerHTML;console.info("Rule:",l);l=k.getElementsByTagName("se:PolygonSymbolizer")[0];k=
l.getElementsByTagName("se:Fill")[0];l=l.getElementsByTagName("se:Stroke")[0];c.polygon={fill:k.querySelector("[name='fill']").innerHTML,stroke:l.querySelector("[name='stroke']").innerHTML,strokeWidth:Number.parseFloat(l.querySelector("[name='stroke-width']").innerHTML)}}}console.info("SLD:",c);b.invoke(netgis.Events.MAP_UPDATE_STYLE,c);return c}}}();netgis=netgis||{};netgis.Toolbar=function(){this.client=null;this.toolbars={};this.searchValue=""};
netgis.Toolbar.prototype.load=function(){var a=this.client.config;this.root=document.createElement("section");this.root.className="netgis-toolbars";if(this.client.editable){var b=1E3,c=3;netgis.util.isDefined(a.tools)&&(netgis.util.isDefined(a.tools.buffer.defaultRadius)&&(b=a.tools.buffer.defaultRadius),netgis.util.isDefined(a.tools.buffer.defaultSegments)&&(c=a.tools.buffer.defaultSegments));this.toolbars[netgis.Modes.DRAW_POINTS]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_POINTS],
this.createToolbarButton('<i class="fas fa-times"></i><span>Punkte zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarCheckbox("Puffern",this.onDrawBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarInput("Radius (Meter):",b,this.onDrawBufferRadiusChange.bind(this)));
this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarInput("Segmente:",c,this.onDrawBufferSegmentsChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POINTS]);this.toolbars[netgis.Modes.DRAW_LINES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarButton('<i class="fas fa-times"></i><span>Linien zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarCheckbox("Einrasten",
this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarCheckbox("Puffern",this.onDrawBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarInput("Radius (Meter):",b,this.onDrawBufferRadiusChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarInput("Segmente:",c,this.onDrawBufferSegmentsChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_LINES]);this.showDrawBufferOptions(!1);
this.toolbars[netgis.Modes.DRAW_POLYGONS]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarButton('<i class="fas fa-times"></i><span>Polygone zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarCheckbox("Tracing",this.onTracingChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POLYGONS]);
this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]=this.createToolbar();this.append(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature zum Ausschneiden w\u00e4hlen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]);this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]=this.createToolbar();this.append(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW],this.createToolbarButton('<i class="fas fa-times"></i><span>Fl\u00e4che zum Ausschneiden zeichnen:</span>',
this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]);this.toolbars[netgis.Modes.MODIFY_FEATURES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.MODIFY_FEATURES],this.createToolbarButton('<i class="fas fa-times"></i><span>Features verschieben:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.MODIFY_FEATURES]);this.toolbars[netgis.Modes.DELETE_FEATURES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DELETE_FEATURES],
this.createToolbarButton('<i class="fas fa-times"></i><span>Features l\u00f6schen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DELETE_FEATURES]);this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]=this.createToolbar();this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature zum Puffern w\u00e4hlen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]);
this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT]=this.createToolbar();this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature puffern:</span>',this.onBufferCancel.bind(this)));this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarInput("Radius (Meter):",b,this.onBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarInput("Segmente:",c,this.onBufferChange.bind(this)));
this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarButton('<i class="fas fa-check"></i><span>OK</span>',this.onBufferAccept.bind(this)));a=this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input");a[0].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].setAttribute("min",1);this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT])}this.toolbars[netgis.Modes.SEARCH_PLACE]=
this.createToolbar();this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],this.createToolbarButton('<i class="fas fa-times"></i><span>Suche:</span>',this.onToolbarClose.bind(this)));a=this.createToolbarInputText("Adresse...","",null);a.style.position="relative";this.searchInput=a.getElementsByTagName("input")[0];this.searchInput.addEventListener("keyup",this.onSearchKeyUp.bind(this));this.searchInput.addEventListener("focus",this.onSearchFocus.bind(this));this.searchInput.addEventListener("blur",
this.onSearchBlur.bind(this));this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],a);this.searchList=document.createElement("ul");this.searchList.className="netgis-dropdown-content netgis-search-list netgis-dialog netgis-shadow netgis-hide";a.appendChild(this.searchList);this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],this.createToolbarButton('<i class="fas fa-undo"></i>',this.onSearchClear.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.SEARCH_PLACE]);this.client.root.appendChild(this.root);
this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SEARCH_PLACE_RESPONSE,this.onSearchPlaceResponse.bind(this))};netgis.Toolbar.prototype.createToolbar=function(){var a=document.createElement("div");a.className="netgis-toolbar netgis-dialog netgis-shadow netgis-hide";var b=document.createElement("div");a.appendChild(b);return a};netgis.Toolbar.prototype.append=function(a,b){a.getElementsByTagName("div")[0].appendChild(b)};
netgis.Toolbar.prototype.createToolbarButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-hover-light";c.innerHTML=a;c.addEventListener("click",b);return c};
netgis.Toolbar.prototype.createToolbarCheckbox=function(a,b){var c=document.createElement("label");c.className="netgis-hover-light";var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",b);c.appendChild(d);a=document.createTextNode(a);c.appendChild(a);return c};
netgis.Toolbar.prototype.createToolbarInput=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";a=document.createTextNode(a);d.appendChild(a);a=document.createElement("input");a.setAttribute("type","number");a.setAttribute("min",0);a.value=b;a.addEventListener("change",c);d.appendChild(a);return d};
netgis.Toolbar.prototype.createToolbarInputText=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";var e=document.createElement("input");e.setAttribute("type","text");e.setAttribute("placeholder",a);e.value=b;c&&e.addEventListener("change",c);d.appendChild(e);return d};
netgis.Toolbar.prototype.onSetMode=function(a){var b=!this.toolbars[netgis.Modes.SEARCH_PLACE].classList.contains("netgis-hide");netgis.util.foreach(this.toolbars,function(b,d){b===a?d.classList.remove("netgis-hide"):d.classList.add("netgis-hide")});switch(a){case netgis.Modes.SEARCH_PLACE:b?this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW):this.searchInput.focus();break;case netgis.Modes.BUFFER_FEATURE_EDIT:this.updateBuffer();break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[1].checked&&
this.client.invoke(netgis.Events.DRAW_BUFFER_ON,null)}};netgis.Toolbar.prototype.onToolbarClose=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbar.prototype.searchRequest=function(a){a=a.trim();a!==this.searchValue&&(this.searchValue=a,0<a.length&&this.client.invoke(netgis.Events.SEARCH_PLACE_REQUEST,{query:a}))};netgis.Toolbar.prototype.searchClear=function(){this.searchInput.value="";this.searchList.innerHTML=""};
netgis.Toolbar.prototype.searchSelectFirst=function(){var a=this.searchList.getElementsByTagName("button");if(0<a.length)this.onSearchItemClick({target:a[0]})};netgis.Toolbar.prototype.onSearchKeyUp=function(a){var b=a.target;switch(a.keyCode){case 13:this.searchSelectFirst();this.searchList.classList.add("netgis-hide");break;case 27:this.searchClear();break;default:this.searchRequest(b.value)}};netgis.Toolbar.prototype.onSearchChange=function(a){this.searchRequest(a.target.value)};
netgis.Toolbar.prototype.onSearchClear=function(a){this.searchClear();this.searchInput.focus()};netgis.Toolbar.prototype.onSearchFocus=function(a){this.searchList.classList.remove("netgis-hide")};netgis.Toolbar.prototype.onSearchBlur=function(a){this.searchList.classList.add("netgis-hide")};
netgis.Toolbar.prototype.onSearchPlaceResponse=function(a){this.searchList.innerHTML="";a=a.geonames;for(var b=0;b<a.length;b++){var c=a[b],d=document.createElement("li");d.className="netgis-hover-light";var e=document.createElement("button");e.setAttribute("type","button");e.innerHTML=c.title;e.dataset.title=c.title;e.dataset.minx=c.minx;e.dataset.miny=c.miny;e.dataset.maxx=c.maxx;e.dataset.maxy=c.maxy;e.addEventListener("mousedown",this.onSearchItemClick.bind(this));d.appendChild(e);this.searchList.appendChild(d)}};
netgis.Toolbar.prototype.onSearchItemClick=function(a){var b=a.target;a=b.dataset.title;var c=Number.parseFloat(b.dataset.minx),d=Number.parseFloat(b.dataset.miny),e=Number.parseFloat(b.dataset.maxx);b=Number.parseFloat(b.dataset.maxy);this.client.invoke(netgis.Events.MAP_SET_EXTENT,{minx:c,miny:d,maxx:e,maxy:b});this.searchValue=a};
netgis.Toolbar.prototype.updateBuffer=function(){var a=this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input"),b=Number.parseFloat(a[0].value);a=Number.parseInt(a[1].value);this.client.invoke(netgis.Events.BUFFER_CHANGE,{radius:b,segments:a})};netgis.Toolbar.prototype.onBufferChange=function(a){this.updateBuffer()};netgis.Toolbar.prototype.onBufferKeyUp=function(a){this.updateBuffer()};
netgis.Toolbar.prototype.onBufferAccept=function(a){this.client.invoke(netgis.Events.BUFFER_ACCEPT,null);this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbar.prototype.onBufferCancel=function(a){this.client.invoke(netgis.Events.BUFFER_CANCEL,null);this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};
netgis.Toolbar.prototype.onSnapChange=function(a){a=a.target.checked;this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[0].checked=a;this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[0].checked=a;this.toolbars[netgis.Modes.DRAW_POLYGONS].getElementsByTagName("input")[0].checked=a;this.client.invoke(a?netgis.Events.SNAP_ON:netgis.Events.SNAP_OFF,null)};
netgis.Toolbar.prototype.onTracingChange=function(a){a=a.target.checked;var b=this.toolbars[netgis.Modes.DRAW_POLYGONS].getElementsByTagName("input")[0],c=b.checked;a&&!c&&(b.checked=a,this.client.invoke(netgis.Events.SNAP_ON,null));this.client.invoke(a?netgis.Events.TRACING_ON:netgis.Events.TRACING_OFF,null)};
netgis.Toolbar.prototype.onDrawBufferChange=function(a){a=a.target.checked;this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[1].checked=a;this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[1].checked=a;this.client.invoke(a?netgis.Events.DRAW_BUFFER_ON:netgis.Events.DRAW_BUFFER_OFF,null);this.showDrawBufferOptions(a)};
netgis.Toolbar.prototype.onDrawBufferRadiusChange=function(a){a=a.target;var b=Number.parseFloat(a.value);this.client.invoke(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,b);var c=this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[2];a!==c&&(c.value=b);c=this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[2];a!==c&&(c.value=b)};
netgis.Toolbar.prototype.onDrawBufferSegmentsChange=function(a){a=a.target;var b=Number.parseInt(a.value);this.client.invoke(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,b);var c=this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[3];a!==c&&(c.value=b);c=this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[3];a!==c&&(c.value=b)};
netgis.Toolbar.prototype.showDrawBufferOptions=function(a){var b=this.toolbars[netgis.Modes.DRAW_POINTS].children[0].children,c=this.toolbars[netgis.Modes.DRAW_LINES].children[0].children;a?(b[3].classList.remove("netgis-hide"),b[4].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide"),c[4].classList.remove("netgis-hide")):(b[3].classList.add("netgis-hide"),b[4].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"),c[4].classList.add("netgis-hide"))};netgis=netgis||{};
netgis.util=function(){var a=function(a,c){for(var b in a)a.hasOwnProperty(b)&&c(b,a[b])};return{isDefined:function(a){return"undefined"!==typeof a},isString:function(a){return"string"===typeof a||a instanceof String},replace:function(a,c,d){return a.replace(new RegExp(c,"g"),d)},foreach:a,template:function(b,c){a(c,function(a,c){b=b.replace(new RegExp("{"+a+"}","g"),c)});return b},newlines:function(a){return a.replace(/\n/g,"<br />")},create:function(a){var b=document.createElement("tbody");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,c){var b=new XMLHttpRequest;b.onload=function(){c(this.responseText)};b.open("GET",a,!0);b.send()},padstr:function(a,c){for(a=a.toString();a.length<c;)a="0"+a;return a},merge:function(a,c){return Object.assign(a,c)},getTimeStamp:function(){var a=new Date,c=a.getDate()+"."+(a.getMonth()+1)+"."+a.getFullYear();return c+=" "+a.getHours()+
":"+a.getMinutes()},formatArea:function(a,c){var b=1E4<a;a=b?c?Math.round(a/1E6*1E3)/1E3:Math.round(a/1E6):c?Math.round(100*a)/100:Math.round(a);0===a&&(b=!1);return a+(b?" qkm":" qm")}}}();
l.getElementsByTagName("se:Fill")[0];l=l.getElementsByTagName("se:Stroke")[0];c.polygon={fill:k.querySelector("[name='fill']").innerHTML,stroke:l.querySelector("[name='stroke']").innerHTML,strokeWidth:Number.parseFloat(l.querySelector("[name='stroke-width']").innerHTML)}}}console.info("SLD:",c);b.invoke(netgis.Events.MAP_UPDATE_STYLE,c);return c}}}();netgis=netgis||{};netgis.Tabs=function(a){this.initElements(a);this.setActiveTab(0)};
netgis.Tabs.prototype.initElements=function(a){this.container=document.createElement("div");this.container.className="netgis-tabs";this.header=document.createElement("div");this.header.className="netgis-header netgis-color-d";this.container.appendChild(this.header);this.content=document.createElement("div");this.content.className="netgis-content netgis-color-e";this.container.appendChild(this.content);for(var b=0;b<a.length;b++){var c=document.createElement("button");c.setAttribute("type","button");
c.addEventListener("click",this.onHeaderButtonClick.bind(this));c.className="netgis-button netgis-color-d";c.innerHTML=a[b];this.header.appendChild(c);c=document.createElement("section");c.className="netgis-color-e netgis-form";this.content.appendChild(c)}};netgis.Tabs.prototype.attachTo=function(a){a.appendChild(this.container)};
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.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))};
netgis.TimeSlider.prototype.setVisible=function(a){a?(this.container.classList.remove("netgis-hide"),this.container.parentNode.classList.add("netgis-footer")):(this.container.classList.add("netgis-hide"),this.container.parentNode.classList.remove("netgis-footer"))};netgis.TimeSlider.prototype.setTitle=function(a){this.header.getElementsByTagName("span")[0].innerHTML=a};netgis.TimeSlider.prototype.clearTimeSteps=function(){this.top.innerHTML=""};
netgis.TimeSlider.prototype.addTimeStep=function(a,b){var c=document.createElement("td");c.setAttribute("data-id",a);a=document.createElement("button");a.className="netgis-button netgis-color-e netgis-hover-d";a.innerHTML="<i class='netgis-icon netgis-text-a far fa-calendar'></i><span>"+b+"</span>";a.setAttribute("type","button");a.addEventListener("click",this.onTimeStepClick.bind(this));c.appendChild(a);this.top.appendChild(c)};
netgis.TimeSlider.prototype.addTimeStep_01=function(a,b){a=document.createElement("td");var c=document.createElement("td");this.insertTop?a.innerHTML=b:c.innerHTML=b;this.top.appendChild(a);this.bottom.appendChild(c);this.insertTop=!this.insertTop};
netgis.TimeSlider.prototype.setActiveTimeStep=function(a){var b=this.top.getElementsByTagName("td"),c=b[a],d=c.getAttribute("data-id");console.info("Set Active Step:",a,d);for(var e=0;e<b.length;e++){var f=b[e],g=f.getElementsByClassName("netgis-icon")[0];e===a?(f.classList.add("netgis-active"),g.classList.remove("fa-calendar"),g.classList.add("fa-calendar-check")):(f.classList.remove("netgis-active"),g.classList.add("fa-calendar"),g.classList.remove("fa-calendar-check"))}c.scrollIntoView();netgis.util.invoke(c,
netgis.Events.TIMESLIDER_SELECT,{layer:this.layerID,time:d})};netgis.TimeSlider.prototype.requestServiceWMST=function(a,b){a=a.trim();1>a.length||(-1===a.indexOf("GetCapabilities")&&(a+="&REQUEST=GetCapabilities"),netgis.util.request(a,this.onServiceResponseWMST.bind(this),{id:b}))};
netgis.TimeSlider.prototype.onServiceResponseWMST=function(a,b){for(var c=(new DOMParser).parseFromString(a,"text/xml").documentElement.getElementsByTagName("Layer"),d,e=0;e<c.length;e++){a=c[e];var f=a.getElementsByTagName("Name")[0].textContent;if(f===b.id){d={name:f,title:a.getElementsByTagName("Title")[0].textContent,abstract:a.getElementsByTagName("Abstract")[0].textContent,queryable:"1"===a.getAttribute("queryable"),opaque:"1"===a.getAttribute("opaque")};e=a.getElementsByTagName("SRS");0<e.length&&
(d.projection=e[0].textContent);e=a.getElementsByTagName("CRS");0<e.length&&(d.projection=e[0].textContent);e=a.getElementsByTagName("BoundingBox")[0];d.bbox=[Number.parseFloat(e.getAttribute("minx")),Number.parseFloat(e.getAttribute("miny")),Number.parseFloat(e.getAttribute("maxx")),Number.parseFloat(e.getAttribute("maxy"))];b=a.getElementsByTagName("Dimension");for(e=0;e<b.length;e++)if(c=b[e],"time"===c.getAttribute("name")){var g={defaultTime:c.getAttribute("default"),extent:c.textContent.split("/")};
break}a=a.getElementsByTagName("Extent");for(e=0;e<a.length;e++)if(b=a[e],"time"===b.getAttribute("name")){g.defaultTime=b.getAttribute("default");g.extent=b.textContent.split("/");break}d.time=g;break}}console.info("WMST Layer:",d);this.setTitle(d.title);if(d.time.extent){g=new Date(d.time.extent[0]);a=new Date(d.time.extent[1]);b=d.time.extent[2];d=[];switch(b){case "P1D":for(;g<=a;)d.push(new Date(g)),g.setDate(g.getDate()+1);break;default:console.error("unsupported WMST date range",b,g,a)}for(e=
0;e<d.length;e++)b=d[e],a=g=b.toISOString(),a=a.replace("T",", "),a=a.replace("Z",""),this.addTimeStep(g,a);this.setActiveTimeStep(d.length-1)}};netgis.TimeSlider.prototype.onTimeSliderShow=function(a){a=a.detail;console.info("TimeSlider Show:",a);this.layerID=a.layer;this.setTitle(a.title);this.clearTimeSteps();this.requestServiceWMST(a.url,a.name);this.setVisible(!0)};netgis.TimeSlider.prototype.onTimeSliderHide=function(a){this.setVisible(!1)};netgis.TimeSlider.prototype.onHeaderClick=function(a){this.setVisible(!1)};
netgis.TimeSlider.prototype.onPointerDown=function(a){a=a.pageX-this.wrapper.offsetLeft;this.down=!0;this.downX=a;this.downScroll=this.wrapper.scrollLeft;this.container.classList.add("netgis-active")};netgis.TimeSlider.prototype.onPointerMove=function(a){this.down&&(a.preventDefault(),this.wrapper.scrollLeft=this.downScroll-(a.pageX-this.wrapper.offsetLeft-this.downX))};netgis.TimeSlider.prototype.onPointerUp=function(a){this.down&&a.preventDefault();this.down=!1;this.container.classList.remove("netgis-active")};
netgis.TimeSlider.prototype.onTimeStepClick=function(a){a=a.currentTarget.parentNode;a.getAttribute("data-id");if(!(5<Math.abs(this.wrapper.scrollLeft-this.downScroll))){for(var b=this.top.getElementsByTagName("td"),c=-1,d=0;d<b.length;d++)if(b[d]===a){c=d;break}this.setActiveTimeStep(c)}};netgis=netgis||{};netgis.Toolbox=function(a){this.config=a;this.bottomPanels={};this.initElements(a);this.initOptions(a);this.initEvents()};
netgis.Toolbox.prototype.initElements=function(a){this.panel=new netgis.Panel("Toolbox");this.panel.content.classList.add("netgis-toolbox");this.top=document.createElement("section");this.panel.content.appendChild(this.top);for(var b=a.toolbox.items,c=0;c<b.length;c++){var d=b[c];if(!1===this.config.tools.editable)switch(d.id){case "draw_points":continue;case "draw_lines":continue;case "draw_polygons":continue;case "modify_features":continue;case "delete_features":continue;case "buffer_features":continue;
case "cut_features":continue}this.addButton(this.top,d.id,d.title)}this.bottom=document.createElement("section");this.bottom.className="netgis-color-e netgis-hide";this.panel.content.appendChild(this.bottom);b=document.createElement("button");b.className="netgis-button netgis-clip-text netgis-color-c";b.innerHTML="<span>Einstellungen</span><i class='netgis-icon fas fa-times'></i>";b.setAttribute("type","button");b.addEventListener("click",this.onBottomHeaderClick.bind(this));this.bottom.appendChild(b);
this.bottomTitle=b.getElementsByTagName("span")[0];a.toolbox&&!0===a.toolbox.open&&this.panel.show()};
netgis.Toolbox.prototype.initOptions=function(a){var b=a.toolbox.options;if(b)for(var c in b);b=a.tools;a=[];this.bottomPanels.drawPoints=document.createElement("div");a.push(this.addCheckbox(this.bottomPanels.drawPoints,"Einrasten",this.onDrawSnapToggle.bind(this)));this.addCheckbox(this.bottomPanels.drawPoints,"Puffern",this.onDrawBufferToggle.bind(this));this.addInputNumber(this.bottomPanels.drawPoints,"Radius (Meter):",b.buffer.default_radius,this.onDrawBufferChange.bind(this));this.addInputNumber(this.bottomPanels.drawPoints,
"Segmente:",b.buffer.default_segments,this.onDrawBufferChange.bind(this));this.bottom.appendChild(this.bottomPanels.drawPoints);this.bottomPanels.drawLines=document.createElement("div");a.push(this.addCheckbox(this.bottomPanels.drawLines,"Einrasten",this.onDrawSnapToggle.bind(this)));this.addCheckbox(this.bottomPanels.drawLines,"Puffern",this.onDrawBufferToggle.bind(this));this.addInputNumber(this.bottomPanels.drawLines,"Radius (Meter):",b.buffer.default_radius,this.onDrawBufferChange.bind(this));
this.addInputNumber(this.bottomPanels.drawLines,"Segmente:",b.buffer.default_segments,this.onDrawBufferChange.bind(this));this.bottom.appendChild(this.bottomPanels.drawLines);this.showDrawBufferOptions(!1);this.bottomPanels.drawPolygons=document.createElement("div");a.push(this.addCheckbox(this.bottomPanels.drawPolygons,"Einrasten",this.onDrawSnapToggle.bind(this)));this.bottom.appendChild(this.bottomPanels.drawPolygons);this.bottomPanels.bufferFeatures=document.createElement("div");this.addInputNumber(this.bottomPanels.bufferFeatures,
"Radius (Meter):",b.buffer.default_radius,this.onBufferFeaturesChange.bind(this));this.addInputNumber(this.bottomPanels.bufferFeatures,"Segmente:",b.buffer.default_segments,this.onBufferFeaturesChange.bind(this));this.addButton(this.bottomPanels.bufferFeatures,null,"<i class='netgis-icon netgis-text-a fas fa-arrow-circle-right'></i><span>Akzeptieren</span>",this.onBufferFeaturesAccept.bind(this));this.bottom.appendChild(this.bottomPanels.bufferFeatures);this.bottomPanels.modifyFeatures=document.createElement("div");
a.push(this.addCheckbox(this.bottomPanels.modifyFeatures,"Einrasten",this.onDrawSnapToggle.bind(this)));this.bottom.appendChild(this.bottomPanels.modifyFeatures);if(!this.config.tools.snapping.show)for(b=0;b<a.length;b++)a[b].parentNode.classList.add("netgis-hide");if(!0===this.config.tools.snapping.active){for(b=0;b<a.length;b++)a[b].checked=!0;var d=this;window.setTimeout(function(){netgis.util.invoke(d.panel.container,netgis.Events.MAP_SNAP_TOGGLE,{on:!0})},100)}};
netgis.Toolbox.prototype.initEvents=function(){this.resizeObserver=(new ResizeObserver(this.onTopResize.bind(this))).observe(this.top)};
netgis.Toolbox.prototype.attachTo=function(a){a.appendChild(this.panel.container);a.addEventListener(netgis.Events.CLIENT_SET_MODE,this.onClientSetMode.bind(this));a.addEventListener(netgis.Events.TOOLBOX_TOGGLE,this.onToolboxToggle.bind(this));a.addEventListener(netgis.Events.LAYERTREE_TOGGLE,this.onLayerTreeToggle.bind(this));a.addEventListener(netgis.Events.SEARCHPARCEL_TOGGLE,this.onSearchParcelToggle.bind(this))};
netgis.Toolbox.prototype.addButton=function(a,b,c,d){var e=document.createElement("button");e.className="netgis-button netgis-clip-text netgis-color-e netgis-hover-d";e.innerHTML=c;e.setAttribute("type","button");e.setAttribute("data-id",b);d?e.onclick=d:e.addEventListener("click",this.onButtonClick.bind(this));a&&a.appendChild(e);return e};
netgis.Toolbox.prototype.addCheckbox=function(a,b,c){var d=document.createElement("label");d.className="netgis-noselect netgis-hover-a";var e=document.createElement("input");e.setAttribute("type","checkbox");d.appendChild(e);var f=document.createElement("span");f.innerHTML=b;d.appendChild(f);c&&(e.onchange=c);a&&a.appendChild(d);return e};
netgis.Toolbox.prototype.addInputNumber=function(a,b,c,d){var e=document.createElement("label");e.className="netgis-noselect netgis-hover-a";var f=document.createElement("span");f.innerHTML=b;e.appendChild(f);b=document.createElement("input");b.setAttribute("type","number");b.setAttribute("min",0);b.value=c;e.appendChild(b);d&&(b.onchange=d,b.onkeyup=d);a&&a.appendChild(e);return b};
netgis.Toolbox.prototype.showBottom=function(a,b){this.top.classList.add("netgis-resize-bottom");this.top.style.height="50%";this.top.style.bottom="auto";this.bottom.classList.remove("netgis-hide");this.bottomTitle.innerHTML=b;if(a)for(var c in this.bottomPanels)b=this.bottomPanels[c],b===a?b.classList.remove("netgis-hide"):b.classList.add("netgis-hide")};
netgis.Toolbox.prototype.hideBottom=function(){this.top.classList.remove("netgis-resize-bottom");this.top.style.height="auto";this.top.style.bottom="0mm";this.bottom.classList.add("netgis-hide")};
netgis.Toolbox.prototype.showDrawBufferOptions=function(a){var b=this.bottomPanels.drawPoints.getElementsByTagName("label"),c=this.bottomPanels.drawLines.getElementsByTagName("label");b[1].getElementsByTagName("input")[0].checked=a;(c[1].getElementsByTagName("input")[0].checked=a)?(b[2].classList.remove("netgis-hide"),b[3].classList.remove("netgis-hide"),c[2].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide")):(b[2].classList.add("netgis-hide"),b[3].classList.add("netgis-hide"),
c[2].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"))};netgis.Toolbox.prototype.setActiveButton=function(a){for(var b=this.top.getElementsByTagName("button"),c=null,d=0;d<b.length;d++){var e=b[d];e.getAttribute("data-id")===a?(c=e,e.classList.add("netgis-active")):e.classList.remove("netgis-active")}if(c){var f=this;window.setTimeout(function(){f.top.scrollTo({top:c.offsetTop,behavior:"smooth"})},10)}};netgis.Toolbox.prototype.onToolboxToggle=function(a){this.panel.toggle()};
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)};
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})};
netgis.Toolbox.prototype.onDrawBufferChange=function(a){a=a.currentTarget.parentNode.parentNode;var b=a.getElementsByTagName("input"),c=b[1].checked,d=Number.parseFloat(b[2].value),e=Number.parseInt(b[3].value);netgis.util.invoke(this.bottomPanels.drawPoints,netgis.Events.DRAW_BUFFER_CHANGE,{on:c,radius:d,segments:e});if(a===this.bottomPanels.drawPoints)var f=this.bottomPanels.drawLines;a===this.bottomPanels.drawLines&&(f=this.bottomPanels.drawPoints);f&&(b=f.getElementsByTagName("input"),b[1].checked=
c,b[2].value=d,b[3].value=e)};netgis.Toolbox.prototype.onBufferFeaturesChange=function(a){var b=this.bottomPanels.bufferFeatures.getElementsByTagName("input");a=Number.parseFloat(b[0].value);b=Number.parseInt(b[1].value);netgis.util.invoke(this.bottomPanels.bufferFeatures,netgis.Events.BUFFER_CHANGE,{radius:a,segments:b})};
netgis.Toolbox.prototype.onBufferFeaturesAccept=function(a){var b=this.bottomPanels.bufferFeatures.getElementsByTagName("input");a=Number.parseFloat(b[0].value);b=Number.parseInt(b[1].value);netgis.util.invoke(this.bottomPanels.bufferFeatures,netgis.Events.BUFFER_ACCEPT,{radius:a,segments:b});netgis.util.invoke(this.bottomPanels.bufferFeatures,netgis.Events.CLIENT_SET_MODE,{mode:netgis.Modes.VIEW})};netgis=netgis||{};netgis.Tree=function(){this.initElements()};netgis.Tree.prototype.initElements=function(){var a=document.createElement("ul");a.className="netgis-tree";this.container=a};netgis.Tree.prototype.attachTo=function(a){a.appendChild(this.container)};netgis.Tree.prototype.clear=function(){this.container.innerHTML=""};
netgis.Tree.prototype.addFolder=function(a,b,c,d,e){var f=document.createElement("li");f.className="netgis-folder";f.setAttribute("data-id",b);b=document.createElement("details");f.appendChild(b);var g=document.createElement("summary");g.className="netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-d";g.innerHTML="<i class='netgis-icon netgis-hide-open fas fa-folder'></i><i class='netgis-icon netgis-show-open fas fa-folder-open'></i><span>"+c+"</span>";b.appendChild(g);c=document.createElement("label");
g.appendChild(c);g=document.createElement("input");g.setAttribute("type","checkbox");g.onchange=this.onFolderChange.bind(this);c.appendChild(g);!0===e&&f.classList.add("netgis-nocheck");e=document.createElement("ul");b.appendChild(e);a=a?a.getElementsByTagName("ul")[0]:this.container;d?a.insertBefore(f,a.firstChild):a.appendChild(f);return f};
netgis.Tree.prototype.addCheckbox=function(a,b,c,d,e,f){var g=document.createElement("li");g.className="netgis-item";var h=document.createElement("label");h.className="netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-d";h.innerHTML="<span>"+c+"</span>";g.appendChild(h);c=document.createElement("input");c.setAttribute("type","checkbox");c.setAttribute("data-id",b);d&&(c.checked=d);c.onchange=this.onItemChange.bind(this);h.insertBefore(c,h.firstChild);f&&this.addItemDetails(g,
b,f);a=a?a.getElementsByTagName("ul")[0]:this.container;e?a.insertBefore(g,a.firstChild):a.appendChild(g);return g};
netgis.Tree.prototype.addRadioButton=function(a,b,c,d,e){var f=document.createElement("li");f.className="netgis-item";var g=document.createElement("label");g.className="netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-d";g.innerHTML="<span>"+c+"</span>";f.appendChild(g);c=a?"radio-"+a.getAttribute("data-id"):"radio-noname";var h=document.createElement("input");h.setAttribute("type","radio");h.setAttribute("name",c);h.setAttribute("value","radio-"+b);h.setAttribute("data-id",
b);d&&(h.checked=d);h.onchange=this.onItemChange.bind(this);g.insertBefore(h,g.firstChild);e&&this.addItemDetails(f,b,e);a?a.getElementsByTagName("ul")[0].appendChild(f):this.container.appendChild(f);return f};
netgis.Tree.prototype.addButton=function(a,b,c,d){var e=document.createElement("li"),f=document.createElement("button");f.innerHTML=c;f.className="netgis-button netgis-color-e netgis-hover-d netgis-clip-text";f.setAttribute("type","button");e.appendChild(f);b&&f.setAttribute("data-id",b);d&&(f.onclick=d);f.addEventListener("click",this.onButtonClick.bind(this));a?a.getElementsByTagName("ul")[0].appendChild(e):this.container.appendChild(e);return e};
netgis.Tree.prototype.addSpace=function(a){var b=document.createElement("li");b.className="netgis-space";a?a.getElementsByTagName("ul")[0].appendChild(b):this.container.appendChild(b);return b};
netgis.Tree.prototype.addItemDetails=function(a,b,c){var d=document.createElement("details");d.className="netgis-noselect";var e=document.createElement("summary");e.className="netgis-clickable netgis-hover-d";e.innerHTML="<i class='fas fa-angle-down'></i>";d.appendChild(e);e=document.createElement("div");d.appendChild(e);for(var f=0;f<c.length;f++){var g=c[f],h=document.createElement("label");e.className="netgis-hover-d";switch(g.type){case "slider":var k=document.createElement("span");k.className=
"netgis-clip-text";k.innerHTML=g.title;h.appendChild(k);k=document.createElement("span");h.appendChild(k);var l=document.createElement("input");l.setAttribute("type","range");l.setAttribute("min",0);l.setAttribute("max",100);l.setAttribute("step",1);l.setAttribute("value",g.val);l.setAttribute("data-id",b);l.addEventListener("change",this.onItemSliderChange.bind(this));l.addEventListener("input",this.onItemSliderChange.bind(this));k.appendChild(l)}e.appendChild(h)}a.appendChild(d)};
netgis.Tree.prototype.getFolder=function(a){for(var b=this.container.getElementsByClassName("netgis-folder"),c=0;c<b.length;c++){var d=b[c];if(d.getAttribute("data-id")===a)return d}return null};netgis.Tree.prototype.getItem=function(a){for(var b=this.container.getElementsByTagName("input"),c=0;c<b.length;c++){var d=b[c];if(d.getAttribute("data-id")===a)return d}return null};
netgis.Tree.prototype.setFolderOpen=function(a,b){var c=this.container.getElementsByClassName("netgis-folder");a=a.toString();for(var d=0;d<c.length;d++){var e=c[d],f=e.getElementsByTagName("details")[0];e.getAttribute("data-id")===a&&(!0===b?f.setAttribute("open",""):f.removeAttribute("open"))}};
netgis.Tree.prototype.setItemChecked=function(a,b,c){var d=this.container.getElementsByClassName("netgis-item");a=a.toString();for(var e=0;e<d.length;e++){var f=d[e],g=f.getElementsByTagName("input")[0];if(g.getAttribute("data-id")===a){if("radio"===g.getAttribute("type")){f=f.parentNode.getElementsByTagName("input");for(var h=0;h<f.length;h++){var k=f[h];k!==g&&"radio"===k.getAttribute("type")&&!1!==k.checked&&(k.checked=!1,netgis.util.invoke(g,netgis.Events.TREE_ITEM_CHANGE,{id:k.getAttribute("data-id"),
checked:!1}))}}c?g.checked=b:g.checked!==b&&g.click()}}};netgis.Tree.prototype.setFolderParent=function(a,b){var c=a.parentNode;c&&c.removeChild(a);null!==b?b.getElementsByTagName("ul")[0].appendChild(a):this.container.appendChild(a)};netgis.Tree.prototype.updateFolderChecks=function(){for(var a=this.container.getElementsByClassName("netgis-folder"),b=0;b<a.length;b++)this.updateFolderCheck(a[b])};
netgis.Tree.prototype.updateFolderCheck=function(a){a||(a=this.container);for(var b=a.getElementsByClassName("netgis-item"),c=0,d=0;d<b.length;d++){var e=b[d].getElementsByTagName("input")[0];e.checked&&c++}e=a.getElementsByTagName("input")[0];d=0;0<c&&(d=1);c===b.length&&(d=2);switch(d){case 0:e.checked=!1;e.classList.remove("netgis-partial");break;case 1:e.checked=!0;e.classList.add("netgis-partial");break;case 2:e.checked=!0,e.classList.remove("netgis-partial")}(a=a.parentElement)&&a!==this.container&&
(a=a.parentElement.parentElement)&&-1!==a.className.search("netgis-folder")&&this.updateFolderCheck(a)};netgis.Tree.prototype.onFolderChange=function(a){var b=a.currentTarget;a=b.checked;b=b.parentElement.parentElement.parentElement.parentElement;for(var c=b.getElementsByTagName("input"),d=1;d<c.length;d++){var e=c[d];e.checked!==a&&e.click()}this.updateFolderCheck(b);a=b.parentElement.parentElement.parentElement;-1!==a.className.search("netgis-folder")&&this.updateFolderCheck(a)};
netgis.Tree.prototype.onItemChange=function(a){a=a.currentTarget;var b=a.checked,c=a.getAttribute("data-id"),d=a.parentElement.parentElement.parentElement.parentElement.parentElement;if("radio"===a.getAttribute("type"))for(var e=a.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("input"),f=0;f<e.length;f++){var g=e[f].getAttribute("data-id");g&&g!==c&&netgis.util.invoke(a,netgis.Events.TREE_ITEM_CHANGE,{id:g,checked:!1})}netgis.util.invoke(a,netgis.Events.TREE_ITEM_CHANGE,{id:c,checked:b});
-1!==d.className.search("netgis-folder")&&this.updateFolderCheck(d)};netgis.Tree.prototype.onRadioChange=function(a){a=a.currentTarget;var b=a.checked,c=a.getAttribute("data-id"),d=Number.parseInt(c);Number.isNaN(d)||(c=d);d=a.parentElement.parentElement.parentElement.parentElement.parentElement;netgis.util.invoke(a,netgis.Events.TREE_ITEM_CHANGE,{id:c,checked:b});-1!==d.className.search("netgis-folder")&&this.updateFolderCheck(d)};
netgis.Tree.prototype.onButtonClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.TREE_BUTTON_CLICK,{id:b})};netgis.Tree.prototype.onItemSliderChange=function(a){a=a.currentTarget;var b=a.getAttribute("data-id");netgis.util.invoke(a,netgis.Events.TREE_ITEM_SLIDER_CHANGE,{id:b,val:Number.parseFloat(a.value)})};netgis=netgis||{};
netgis.util=function(){var a=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(c,a[c])},b=function(){return navigator.language||"de-DE"};return{isDefined:function(a){return"undefined"!==typeof a},isObject:function(a){return"object"!==typeof a||Array.isArray(a)||null===a?!1:!0},isString:function(a){return"string"===typeof a||a instanceof String},clone:function(a){return JSON.parse(JSON.stringify(a))},stringToID:function(a,b){b||(b="-");a=a.trim();a=a.toLowerCase();a=this.replace(a," ",b);a=this.replace(a,
"\n",b);a=this.replace(a,"\t",b);a=this.replace(a,"\\.",b);a=this.replace(a,"\\,",b);a=this.replace(a,"\\!",b);a=this.replace(a,"\\?",b);a=this.replace(a,":",b);a=this.replace(a,";",b);a=this.replace(a,'"',b);a=this.replace(a,"'",b);a=this.replace(a,"\\\u00a7",b);a=this.replace(a,"\\$",b);a=this.replace(a,"\\%",b);a=this.replace(a,"\\&",b);a=this.replace(a,"\\/",b);a=this.replace(a,"\\\\",b);a=this.replace(a,"\\(",b);a=this.replace(a,"\\)",b);a=this.replace(a,"\\{",b);a=this.replace(a,"\\}",b);a=
this.replace(a,"\\[",b);a=this.replace(a,"\\]",b);a=this.replace(a,"=",b);a=this.replace(a,"\\+",b);a=this.replace(a,"\\*",b);a=this.replace(a,"\\~",b);a=this.replace(a,"\\^",b);a=this.replace(a,"\\\u00b0",b);a=this.replace(a,"\u00b2",b);a=this.replace(a,"\u00b3",b);a=this.replace(a,"\\#",b);a=this.replace(a,"\\<",b);a=this.replace(a,"\\>",b);a=this.replace(a,"\\|",b);a=this.replace(a,"\\@",b);a=this.replace(a,"\u20ac",b);a=this.replace(a,"\u00b5",b);a=this.trim(a,b);a=this.replace(a,"\u00e4","ae");
a=this.replace(a,"\u00f6","oe");a=this.replace(a,"\u00fc","ue");a=this.replace(a,"\u00df","ss");a=this.replace(a,"\u00e1","a");a=this.replace(a,"\u00e0","a");a=this.replace(a,"\u00e2","a");a=this.replace(a,"\u00e9","e");a=this.replace(a,"\u00e8","e");a=this.replace(a,"\u00ea","e");a=this.replace(a,"\u00ed","i");a=this.replace(a,"\u00ec","i");a=this.replace(a,"\u00ee","i");a=this.replace(a,"\u00f3","o");a=this.replace(a,"\u00f2","o");a=this.replace(a,"\u00f4","o");a=this.replace(a,"\u00fa","u");a=
this.replace(a,"\u00f9","u");return a=this.replace(a,"\u00fb","u")},replace:function(a,b,e){return a.replace(new RegExp(b,"g"),e)},trim:function(a,b){a=a.replace(new RegExp("^"+b+"+"),"");return a=a.replace(new RegExp(b+"+$"),"")},foreach:a,template:function(b,d){a(d,function(a,c){b=b.replace(new RegExp("{"+a+"}","g"),c)});return b},newlines:function(a){return a.replace(/\n/g,"<br />")},create:function(a){var b=document.createElement("tbody");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))};
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.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};
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);console.info("WMC Layers:",this.layers)};
netgis.WMC.prototype.toConfig=function(){for(var a={title:"<b>GeoPortal</b>",modules:{search_parcel:!1},map:{attribution:this.title+", GeoPortal RLP",projection:this.crs,bbox:this.bbox,scalebar:!0},search:{url:"./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}"}},b=[],c=[],d=this.layers.length,e=0;e<this.services.length;e++){var f=
this.services[e],g=f.layers[0];b.push({id:g.id,title:g.title,parent:-1});for(var h=b.length-1,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};

1
dist/netgis_old.min.css vendored Normal file

File diff suppressed because one or more lines are too long

336
dist/netgis_old.min.js vendored Normal file
View File

@ -0,0 +1,336 @@
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Number.parseFloat",function(a){return a||parseFloat},"es6","es3");$jscomp.polyfill("Number.parseInt",function(a){return a||parseInt},"es6","es3");
$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,c,d){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==d||d>b)d=b;d=Number(d);0>d&&(d=Math.max(0,b+d));for(c=Number(c||0);c<d;c++)this[c]=a;return this}},"es6","es3");$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};
$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var e=c++;return{value:b(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};$jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a,c){return c})}},"es8","es3");
$jscomp.polyfill("Number.isFinite",function(a){return a?a:function(a){return"number"!==typeof a?!1:!isNaN(a)&&Infinity!==a&&-Infinity!==a}},"es6","es3");$jscomp.polyfill("Number.isNaN",function(a){return a?a:function(a){return"number"===typeof a&&isNaN(a)}},"es6","es3");$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};
$jscomp.assign="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");var netgis=netgis||{};netgis.Attribution=function(){this.layers=this.client=null;this.items=[]};
netgis.Attribution.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-attribution netgis-text-primary";netgis.util.isDefined(this.client.config.map)&&netgis.util.isDefined(this.client.config.map.attribution)&&this.items.push(this.client.config.map.attribution);this.update();this.client.root.appendChild(this.root);this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.LAYER_SHOW,this.onLayerShow.bind(this));
this.client.on(netgis.Events.LAYER_HIDE,this.onLayerHide.bind(this));this.client.on(netgis.Events.EDIT_FEATURES_CHANGE,this.onEditFeaturesChange.bind(this))};netgis.Attribution.prototype.update=function(){var a="&copy; "+this.items.join(", ");this.appendix&&(a+=", "+this.appendix);this.root.innerHTML=a};
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.onEditFeaturesChange=function(a){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.area&&0<a.area?"<b>Zeichnungsfl\u00e4che: "+netgis.util.formatArea(a.area,!0)+"</b>":null;this.update()};netgis=netgis||{};
netgis.Client=function(a,b){this.build="20220826";this.debug=!1;netgis.util.isString(a)&&(a=document.getElementById(a));this.container=a;this.editable=!0;this.root=null;this.modules=[];this.callbacks={};this.config=this.createDefaultConfig();this.create();if(netgis.util.isDefined(b))if(netgis.util.isString(b)){var c=this;netgis.util.request(b,function(a){a=JSON.parse(a);netgis.util.merge(c.config,a);c.applyConfig(c.config)})}else netgis.util.merge(this.config,b),this.applyConfig(this.config);else this.applyConfig(this.config);
this.hideLoader()};netgis.Client.Layers=Object.freeze({PARCEL_DISTRICTS:"parcel-districts",PARCEL_FIELDS:"parcel-fields",PARCEL_FEATURES:"parcel-features",EDIT_LAYER:"edit-layer",PREVIEW_LAYER:"preview-layer"});netgis.Client.prototype.applyConfig=function(a){this.createModules();this.load();this.invoke(netgis.Events.CONTEXT_UPDATE,a);this.initModules(a);this.initConfig(a);this.initOutput(a);this.initEvents();this.importLayers={};this.setMode(netgis.Modes.VIEW)};
netgis.Client.prototype.initElements=function(){};
netgis.Client.prototype.initModules=function(a){this.map=new netgis.MapOpenLayers(a);this.map.attach(this.root);this.controls=new netgis.Controls;this.controls.attach(this.root);this.layerPanel=new netgis.Panel("Inhalte");this.layerPanel.attach(this.root);this.layerTree=new netgis.Tree;this.layerTree.container.style.position="absolute";this.layerTree.container.style.width="100%";this.layerTree.container.style.top="12mm";this.layerTree.container.style.bottom="6mm";this.layerTree.container.style.overflow=
"auto";this.layerTree.attach(this.layerPanel.container);this.toolboxPanel=new netgis.Panel("Werkzeuge");this.toolboxPanel.attach(this.root);this.toolbox=new netgis.Toolbox(a);this.toolbox.attach(this.toolboxPanel.container);this.searchPlace=new netgis.SearchPlace(a);this.searchPlace.attach(this.root);this.parcelPanel=new netgis.Panel("Flurst\u00fccks-Suche");this.parcelPanel.container.style.minWidth="92mm";this.parcelPanel.attach(this.root);this.searchParcel=new netgis.SearchParcel(a,this);this.searchParcel.attach(this.parcelPanel.container);
this.importModal=new netgis.Modal("Ebene hinzuf\u00fcgen");this.importModal.container.classList.add("netgis-import");this.importModal.attach(this.root);a=document.createElement("div");a.className="netgis-content netgis-form netgis-noselect";this.importModal.content.appendChild(a);var b=document.createElement("label");b.innerHTML="Dateiformat:";a.appendChild(b);var c=document.createElement("select");c.innerHTML="<option value='geojson'>GeoJSON</option><option value='gml'>GML</option><option value='gpkg'>GeoPackage</option><option value='shp'>Shapefile (Zip)</option><option value='spatialite'>Spatialite</option>";
b.addEventListener("change",this.onImportFileTypeChange.bind(this));b.appendChild(c);this.importFileSelect=c;b=document.createElement("div");b.innerHTML="<h3>Unterst\u00fctzte Koordinatensysteme:</h3><ul><li>World Geodetic System 1984 (EPSG:4326)</li><li>ETRS89 / UTM zone 32N (EPSG:25832)</li></ul>";a.appendChild(b);b=document.createElement("label");b.innerHTML="Datei ausw\u00e4hlen/ablegen:";a.appendChild(b);c=document.createElement("input");c.className="netgis-color-d";c.setAttribute("type","file");
c.setAttribute("accept",".geojson,.json");b.appendChild(c);this.importFileInput=c;b=document.createElement("button");b.setAttribute("type","button");b.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";b.innerHTML="<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>";b.addEventListener("click",this.onImportFileClick.bind(this));a.appendChild(b);this.importServiceModal=new netgis.Modal("Dienst hinzuf\u00fcgen");this.importServiceModal.container.classList.add("netgis-import");
this.importServiceModal.attach(this.root);b=document.createElement("div");b.className="netgis-content netgis-form netgis-noselect";this.importServiceModal.content.appendChild(b);a=document.createElement("label");a.innerHTML="WMS/WFS URL:";b.appendChild(a);c=document.createElement("input");c.setAttribute("type","text");a.appendChild(c);this.importServiceInput=c;a=document.createElement("button");a.setAttribute("type","button");a.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";
a.innerHTML="<i class='netgis-icon fas fa-cloud-download-alt'></i><span>Dienst laden</span>";a.style.marginBottom="6mm";a.addEventListener("click",this.onImportServiceClick.bind(this));b.appendChild(a);a=document.createElement("div");a.className="netgis-hide";b.appendChild(a);this.importServiceDetails=a;b=document.createElement("label");b.innerHTML="Bezeichnung:";a.appendChild(b);c=document.createElement("input");c.setAttribute("type","text");b.appendChild(c);this.importServiceNameInput=c;b=document.createElement("label");
b.innerHTML="Kartenebene:";a.appendChild(b);c=document.createElement("select");b.appendChild(c);this.importServiceLayerSelect=c;b=document.createElement("label");b.innerHTML="Format:";a.appendChild(b);c=document.createElement("select");b.appendChild(c);this.importServiceFormatSelect=c;b=document.createElement("button");b.setAttribute("type","button");b.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";b.innerHTML="<i class='netgis-icon fas fa-check'></i><span>Hinzuf\u00fcgen</span>";
b.addEventListener("click",this.onImportServiceAccept.bind(this));a.appendChild(b);this.exportModal=new netgis.Modal("Exportieren");this.exportModal.container.classList.add("netgis-export");this.exportModal.attach(this.root);a=document.createElement("div");a.className="netgis-form netgis-noselect";a.style.position="absolute";a.style.width="100%";a.style.top="12mm";a.style.bottom="0mm";a.style.overflow="auto";a.style.padding="12mm";this.exportModal.content.appendChild(a);b=document.createElement("label");
b.innerHTML="Format:";a.appendChild(b);c=document.createElement("select");c.innerHTML="<option value='pdf'>PDF</option><option value='jpeg'>JPEG</option><option value='png'>PNG</option><option value='gif'>GIF</option>";c.addEventListener("change",this.onExportFormatChange.bind(this));b.appendChild(c);this.exportFormatSelect=c;b=document.createElement("label");b.innerHTML="Breite (Pixel):";a.appendChild(b);c=document.createElement("input");c.setAttribute("type","number");c.setAttribute("min",0);b.appendChild(c);
this.exportWidthInput=c;b=document.createElement("label");b.innerHTML="H\u00f6he (Pixel):";a.appendChild(b);c=document.createElement("input");c.setAttribute("type","number");c.setAttribute("min",0);b.appendChild(c);this.exportHeightInput=c;b=document.createElement("label");b.innerHTML="Seitenr\u00e4nder (Millimeter):";a.appendChild(b);c=document.createElement("input");c.setAttribute("type","number");c.setAttribute("min",0);c.value=10;b.appendChild(c);this.exportPaddingInput=c;b=document.createElement("label");
b.innerHTML="Querformat:";a.appendChild(b);c=document.createElement("input");c.setAttribute("type","checkbox");b.appendChild(c);this.exportLandscapeInput=c;b=document.createElement("button");b.setAttribute("type","button");b.className="netgis-button netgis-center netgis-color-a netgis-hover-c netgis-shadow";b.innerHTML="<i class='netgis-icon fas fa-check'></i><span>Exportieren</span>";b.addEventListener("click",this.onExportButtonClick.bind(this));a.appendChild(b)};
netgis.Client.prototype.initConfig=function(a){var b=[],c=a.folders;if(c){for(var d=0;d<c.length;d++){var e=1E3+d,f=this.layerTree.addFolder(null,e,c[d].title);b.push(f)}for(d=0;d<c.length;d++)e=c[d].parent,-1<e&&this.layerTree.setFolderParent(b[d],b[e])}if(c=a.layers)for(d=0;d<c.length;d++){var g=c[d];f=-1<g.folder?b[g.folder]:null;e=g.id;e||(e=1E3+d,g.id=e);this.layerTree.addCheckbox(f,e,g.title);g.active&&(this.map.addLayer(e,this.map.createLayer(g)),this.layerTree.setItemChecked(e,!0))}this.importFolder=
this.layerTree.addFolder(null,"import","Importierte Ebenen",!0);this.importFolder.classList.add("netgis-hide");this.editFolder=this.layerTree.addFolder(null,"edit-folder","Zeichnung",!0);this.editFolder.classList.add("netgis-hide");this.layerTree.addCheckbox(this.editFolder,"edit-layer","Zeichnung");this.layerTree.setItemChecked("edit-layer",!0);this.importButton=this.layerTree.addButton(null,"<i class='netgis-icon fas fa-plus' style='font-size: 1em;'></i><span>Dienst hinzuf\u00fcgen...</span>",this.onLayerTreeImportClick.bind(this));
this.attribution.onContextUpdate(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);this.map.addEditFeaturesGeoJSON(b,!1);var c=this;window.setTimeout(function(){c.map.map.updateSize();c.map.zoomGeoJSON(b)},50);this.editFolder.classList.remove("netgis-hide")}this.output=a}this.output||(this.output=document.createElement("input"),this.output.setAttribute("type","hidden"),this.output.className="netgis-storage",this.root.appendChild(this.output))};
netgis.Client.prototype.initEvents=function(){this.container.addEventListener(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.container.addEventListener(netgis.Events.PANEL_TOGGLE,this.onPanelToggle.bind(this));this.container.addEventListener(netgis.Events.PANEL_RESIZE,this.onPanelResize.bind(this));this.container.addEventListener(netgis.Events.LAYERS_TOGGLE,this.onLayersToggle.bind(this));this.container.addEventListener(netgis.SearchPlace.Events.TOGGLE,this.onSearchPlaceToggle.bind(this));
this.container.addEventListener(netgis.SearchParcel.Events.TOGGLE,this.onSearchParcelToggle.bind(this));this.container.addEventListener(netgis.Events.CONTROLS_ZOOM,this.onControlsZoom.bind(this));this.container.addEventListener(netgis.Events.CONTROLS_ZOOM_ALL,this.onControlsZoomAll.bind(this));this.container.addEventListener(netgis.Events.TOOLBOX_TOGGLE,this.onToolboxToggle.bind(this));this.parcelPanel.container.addEventListener(netgis.Events.PANEL_TOGGLE,this.onParcelsPanelToggle.bind(this));this.container.addEventListener(netgis.Events.PARCELS_RESET,
this.onParcelsReset.bind(this));this.container.addEventListener(netgis.Events.PARCELS_FIELDS_RESPONSE,this.onParcelsFieldsResponse.bind(this));this.container.addEventListener(netgis.Events.PARCELS_RESPONSE,this.onParcelsResponse.bind(this));this.container.addEventListener(netgis.Events.PARCELS_ITEM_ENTER,this.onParcelsItemEnter.bind(this));this.container.addEventListener(netgis.Events.PARCELS_ITEM_LEAVE,this.onParcelsItemLeave.bind(this));this.container.addEventListener(netgis.Events.PARCELS_ITEM_CLICK,
this.onParcelsItemClick.bind(this));this.container.addEventListener(netgis.Events.PARCELS_ITEM_IMPORT_CLICK,this.onParcelsImportClick.bind(this));this.container.addEventListener(netgis.Events.MAP_FEATURE_ENTER,this.onMapFeatureEnter.bind(this));this.container.addEventListener(netgis.Events.MAP_FEATURE_CLICK,this.onMapFeatureClick.bind(this));this.container.addEventListener(netgis.Events.MAP_FEATURE_LEAVE,this.onMapFeatureLeave.bind(this));this.container.addEventListener(netgis.Events.LAYER_CREATED,
this.onLayerCreated.bind(this));this.layerTree.container.addEventListener(netgis.Tree.Events.ITEM_CHANGE,this.onLayerTreeItemChange.bind(this));this.searchPlace.container.addEventListener(netgis.SearchPlace.Events.SELECT,this.onSearchPlaceSelect.bind(this));this.container.addEventListener(netgis.Events.SNAP_TOGGLE,this.onSnapToggle.bind(this));this.container.addEventListener(netgis.Events.TRACING_TOGGLE,this.onTracingToggle.bind(this));this.container.addEventListener(netgis.Events.BUFFER_TOGGLE,this.onBufferToggle.bind(this));
this.container.addEventListener(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,this.onBufferRadiusChange.bind(this));this.container.addEventListener(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,this.onBufferSegmentsChange.bind(this));this.container.addEventListener(netgis.Events.BUFFER_CHANGE,this.onBufferFeatureChange.bind(this));this.container.addEventListener(netgis.Events.BUFFER_ACCEPT,this.onBufferFeatureAccept.bind(this));this.container.addEventListener(netgis.Events.IMPORT_SHAPEFILE_SHOW,this.onImportShapefileShow.bind(this));
this.container.addEventListener(netgis.Events.IMPORT_GEOJSON_SHOW,this.onImportGeoJSONShow.bind(this));this.container.addEventListener(netgis.Events.IMPORT_GML_SHOW,this.onImportGMLShow.bind(this));this.container.addEventListener(netgis.Events.IMPORT_SPATIALITE_SHOW,this.onImportSpatialiteShow.bind(this));this.container.addEventListener(netgis.Events.IMPORT_GEOPACKAGE_SHOW,this.onImportGeopackageShow.bind(this));this.container.addEventListener(netgis.Events.EXPORT_PDF_SHOW,this.onExportPDFShow.bind(this));
this.container.addEventListener(netgis.Events.EXPORT_PNG_SHOW,this.onExportPNGShow.bind(this));this.container.addEventListener(netgis.Events.EXPORT_JPEG_SHOW,this.onExportJPEGShow.bind(this));this.container.addEventListener(netgis.Events.EXPORT_GIF_SHOW,this.onExportGIFShow.bind(this));this.container.addEventListener(netgis.Events.EXPORT_PDF,this.onExportPDF.bind(this));this.container.addEventListener(netgis.Events.EXPORT_PNG,this.onExportPNG.bind(this));this.container.addEventListener(netgis.Events.EXPORT_JPEG,
this.onExportJPEG.bind(this));this.container.addEventListener(netgis.Events.EXPORT_GIF,this.onExportGIF.bind(this));this.container.addEventListener(netgis.Events.EDIT_FEATURES_CHANGE,this.onEditFeaturesChange.bind(this));this.container.addEventListener(netgis.Events.IMPORT_SHOW,this.onImportShow.bind(this));this.container.addEventListener(netgis.Events.EXPORT_SHOW,this.onExportShow.bind(this))};
netgis.Client.prototype.createDefaultConfig=function(){return{map:{projection:"EPSG:3857",center:[1113194,6621293],minZoom:0,maxZoom:20,zoom:6,attribution:"NetGIS"},projections:[],layers:[{folder:0,type:netgis.LayerTypes.OSM,title:"Open Street Map",attribution:"OSM Contributors",active:!0}],folders:[{title:"Hintergrund",parent:-1}],styles:{editLayer:{fill:"rgba( 255, 0, 0, 0.5 )",stroke:"#ff0000",strokeWidth:3,pointRadius:6},select:{fill:"rgba( 0, 127, 255, 0.5 )",stroke:"#007fff",strokeWidth:3,pointRadius:6},
sketch:{fill:"rgba( 0, 127, 0, 0.5 )",stroke:"#007f00",strokeWidth:3,pointRadius:6},modify:{fill:"rgba( 0, 127, 0, 0.5 )",stroke:"#007f00",strokeWidth:3,pointRadius:6},parcel:{fill:"rgba( 127, 255, 255, 0.5 )",stroke:"#7fffff",strokeWidth:3}}}};
netgis.Client.prototype.create=function(){this.root=document.createElement("section");this.root.className="netgis-client";this.loader=document.createElement("div");this.loader.className="netgis-loader netgis-dialog netgis-text-primary";this.loader.innerHTML="<i class='fas fa-spinner'></i>";this.root.appendChild(this.loader);this.container.appendChild(this.root)};
netgis.Client.prototype.createModules=function(){this.editable=!0;this.container.hasAttribute("contenteditable")&&"false"===this.container.getAttribute("contenteditable")&&(this.editable=!1);this.container.hasAttribute("data-editable")&&(this.editable="true"===this.container.getAttribute("data-editable")?!0:!1);this.add(this.attribution=new netgis.Attribution);this.add(new netgis.Toolbar);this.add(new netgis.Menu)};
netgis.Client.prototype.load=function(){for(var a=0;a<this.modules.length;a++)this.modules[a].load();this.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW);this.on(netgis.Events.EXPORT_BEGIN,this.onMapExportBegin.bind(this));this.on(netgis.Events.EXPORT_END,this.onMapExportEnd.bind(this));this.on(netgis.Events.EDIT_FEATURES_CHANGE,this.onEditFeaturesChange.bind(this))};netgis.Client.prototype.add=function(a){a.client=this;this.modules.push(a)};
netgis.Client.prototype.on=function(a,b){netgis.util.isDefined(this.callbacks[a])||(this.callbacks[a]=[]);this.callbacks[a].push(b)};netgis.Client.prototype.off=function(a,b){if(netgis.util.isDefined(this.callbacks[a]))if(netgis.util.isDefined(b)){for(var c=0;c<this.callbacks[a].length;c++)if(this.callbacks[a][c]===b){this.callbacks[a].splice(c,1);break}1>this.callbacks[a].length&&delete this.callbacks[a]}else delete this.callbacks[a]};
netgis.Client.prototype.invoke=function(a,b){this.debug&&console.info("EVENT:",a,b);if(netgis.util.isDefined(this.callbacks[a]))for(var c=0;c<this.callbacks[a].length;c++)this.callbacks[a][c](b)};netgis.Client.prototype.showLoader=function(){this.loader.classList.remove("netgis-hide")};netgis.Client.prototype.hideLoader=function(){this.loader.classList.add("netgis-hide")};netgis.Client.prototype.onHtmlResponse=function(a){this.root=netgis.util.create(a);this.container.appendChild(this.root)};
netgis.Client.prototype.onEditFeaturesChange=function(a){var b=JSON.stringify(a.detail);this.output.value=b;this.attribution.onEditFeaturesChange(a.detail)};netgis.Client.prototype.onMapExportBegin=function(a){this.showLoader()};netgis.Client.prototype.onMapExportEnd=function(a){this.hideLoader()};netgis.Client.prototype.setMode=function(a){this.map.setMode(a);this.toolbox.setMode(a)};
netgis.Client.prototype.onPanelToggle=function(a){a=a.detail;a.visible?this.map.setPadding(0,0,0,a.panel.width()):(a=!1,this.layerPanel.visible()&&(a=!0),this.toolboxPanel.visible()&&(a=!0),this.parcelPanel.visible()&&(a=!0),a||this.map.setPadding(0,0,0,0))};netgis.Client.prototype.onPanelResize=function(a){this.map.setPadding(0,0,0,a.detail.width)};netgis.Client.prototype.onLayerCreated=function(a){a.detail.id===this.map.editLayerID&&this.editFolder.classList.remove("netgis-hide")};
netgis.Client.prototype.onLayersToggle=function(a){this.layerPanel.toggle();this.layerPanel.visible()&&(this.toolboxPanel.hide(),this.parcelPanel.hide())};
netgis.Client.prototype.onLayerTreeItemChange=function(a){var b=a.detail.id;a=a.detail.checked;switch(b){default:for(var c=this.config.layers,d=!1,e=null,f=0;f<c.length;f++){var g=c[f],h=g.id;if(h===b){e=this.map.createLayer(g);d=!0;break}}if(!d)for(h in this.importLayers)if(h===b){e=this.importLayers[b];d=!0;break}d&&(a?(this.map.addLayer(b,e),this.attribution.onLayerShow({id:b})):(this.map.removeLayer(b),this.attribution.onLayerHide({id:b})));break;case "edit-layer":a?this.map.addLayer(netgis.Client.Layers.EDIT_LAYER,
this.map.editLayer):this.map.removeLayer(netgis.Client.Layers.EDIT_LAYER)}};netgis.Client.prototype.onToolboxToggle=function(a){this.toolboxPanel.toggle();this.toolboxPanel.visible()&&(this.layerPanel.hide(),this.parcelPanel.hide())};netgis.Client.prototype.onSearchPlaceToggle=function(a){this.searchPlace.toggle()};netgis.Client.prototype.onSearchPlaceSelect=function(a){a=a.detail;this.map.zoomExtent(a.minx,a.miny,a.maxx,a.maxy)};
netgis.Client.prototype.onSearchParcelToggle=function(a){this.parcelPanel.toggle();this.parcelPanel.visible()&&(this.layerPanel.hide(),this.toolboxPanel.hide())};netgis.Client.prototype.onControlsZoom=function(a){this.map.zoom(a.detail)};netgis.Client.prototype.onControlsZoomAll=function(a){this.map.zoomAll()};netgis.Client.prototype.onParcelsPanelToggle=function(a){this.searchParcel.reset()};
netgis.Client.prototype.onParcelsReset=function(a){this.map.removeLayer(netgis.Client.Layers.PARCEL_DISTRICTS);this.map.removeLayer(netgis.Client.Layers.PARCEL_FIELDS);this.map.removeLayer(netgis.Client.Layers.PARCEL_FEATURES);if(this.parcelPanel.visible()){this.parcelsAdded=[];var b=this.config.searchParcel.districts_service;a=this.map.createLayer(b);var c=this.config.styles.parcel;this.map.setLayerStyleSimple(a,c.fill,c.stroke,c.width);this.map.setLayerOrder(a,99999);this.map.addLayer(netgis.Client.Layers.PARCEL_DISTRICTS,
a);if(b.minZoom){var d=this;window.setTimeout(function(){d.map.zoomLevel(b.minZoom+1)},50)}this.setMode(netgis.Modes.PARCEL_SELECT)}else this.setMode(netgis.Modes.VIEW)};
netgis.Client.prototype.onParcelsFieldsResponse=function(a){var b=a.detail;this.map.zoomGeoJSON(b.geojson);this.map.removeLayer(netgis.Client.Layers.PARCEL_DISTRICTS);a=this.config.styles.parcel;b=this.map.createLayerGeoJSON(b.geojson,!1);this.map.setLayerStyleSimple(b,a.fill,a.stroke,a.width);this.map.setLayerOrder(b,99999);this.map.addLayer(netgis.Client.Layers.PARCEL_FIELDS,b)};
netgis.Client.prototype.onParcelsResponse=function(a){a=this.map.createLayerWKT(a.detail.parcels);var b=this.config.styles.parcel;this.map.removeLayer(netgis.Client.Layers.PARCEL_DISTRICTS);this.map.removeLayer(netgis.Client.Layers.PARCEL_FIELDS);this.map.removeLayer(netgis.Client.Layers.PARCEL_FEATURES);this.map.setLayerStyleSimple(a,b.fill,b.stroke,b.width);this.map.setLayerOrder(a,99999);this.map.addLayer(netgis.Client.Layers.PARCEL_FEATURES,a);this.map.zoomLayer(netgis.Client.Layers.PARCEL_FEATURES)};
netgis.Client.prototype.onMapFeatureEnter=function(a){a=a.detail;switch(a.layer){case netgis.Client.Layers.PARCEL_DISTRICTS:a=a.properties.gemarkung;this.map.container.setAttribute("title",a);break;case netgis.Client.Layers.PARCEL_FIELDS:a=a.properties.flurname;this.map.container.setAttribute("title",a);break;case netgis.Client.Layers.PARCEL_FEATURES:a="Flur: "+a.properties.fln+" / Z\u00e4hler: "+a.properties.fsn_zae+" / Nenner: "+a.properties.fsn_nen,this.editable&&(a+=" (Klicken zum \u00dcbernehmen der Geometrie)"),
this.map.container.setAttribute("title",a)}};
netgis.Client.prototype.onMapFeatureClick=function(a){a=a.detail;switch(a.layer){default:console.info("Feature Click:",a);break;case netgis.Client.Layers.PARCEL_DISTRICTS:this.searchParcel.setDistrict(a.properties.gemarkung+" ("+a.properties.ldkreis+")",a.properties.gmkgnr);break;case netgis.Client.Layers.PARCEL_FIELDS:this.searchParcel.setFieldNumber(a.properties.flur);break;case netgis.Client.Layers.PARCEL_FEATURES:if(!0===this.editable){var b=a.properties.fsk;-1===this.parcelsAdded.indexOf(b)&&
(this.map.addEditFeature(this.map.createFeatureJSON(a.properties)),this.map.updateSnapFeatures(),this.parcelsAdded.push(b))}}};netgis.Client.prototype.onMapFeatureLeave=function(a){this.map.container.setAttribute("title","")};netgis.Client.prototype.onParcelsItemEnter=function(a){this.map.setFeatureHover(this.map.findFeature(netgis.Client.Layers.PARCEL_FEATURES,"fsk",a.detail.id),!0)};
netgis.Client.prototype.onParcelsItemLeave=function(a){this.map.setFeatureHover(this.map.findFeature(netgis.Client.Layers.PARCEL_FEATURES,"fsk",a.detail.id),!1)};netgis.Client.prototype.onParcelsItemClick=function(a){this.map.zoomFeature(this.map.findFeature(netgis.Client.Layers.PARCEL_FEATURES,"fsk",a.detail.id))};netgis.Client.prototype.onParcelsImportClick=function(a){a=a.detail;!1!==this.editable&&(this.map.addEditFeature(this.map.createFeatureWKT(a.geom,{id:a.id})),this.map.updateSnapFeatures())};
netgis.Client.prototype.onSetMode=function(a){this.setMode(a.detail)};netgis.Client.prototype.onSnapToggle=function(a){(a=a.detail.target.checked)?(this.map.updateSnapFeatures(),this.map.setSnapOn()):this.map.setSnapOff();this.toolbox.setSnap(a)};netgis.Client.prototype.onTracingToggle=function(a){a.detail.target.checked?(this.map.updateSnapFeatures(),this.map.setSnapOn(),this.map.setTracingOn(),this.toolbox.setSnap(!0)):this.map.setTracingOff()};
netgis.Client.prototype.onBufferToggle=function(a){if(a=a.detail.target.checked)this.map.onDrawBufferOn();else this.map.onDrawBufferOff();this.toolbox.setBuffer(a)};netgis.Client.prototype.onBufferRadiusChange=function(a){a=Number.parseFloat(a.detail.target.value);this.map.onDrawBufferRadiusChange(a);this.toolbox.setBufferRadius(a)};netgis.Client.prototype.onBufferSegmentsChange=function(a){a=Number.parseInt(a.detail.target.value);this.map.onDrawBufferSegmentsChange(a);this.toolbox.setBufferSegments(a)};
netgis.Client.prototype.onBufferFeatureChange=function(a){this.map.onBufferChange(a.detail)};netgis.Client.prototype.onBufferFeatureAccept=function(a){this.map.onBufferAccept()};netgis.Client.prototype.onImportShapefileShow=function(a){this.modal.onImportShapefileShow(a)};netgis.Client.prototype.onImportGeoJSONShow=function(a){this.modal.onImportGeoJSONShow(a)};netgis.Client.prototype.onImportGMLShow=function(a){this.modal.onImportGMLShow(a)};netgis.Client.prototype.onImportSpatialiteShow=function(a){this.modal.onImportSpatialiteShow(a)};
netgis.Client.prototype.onImportGeopackageShow=function(a){this.modal.onImportGeopackageShow(a)};netgis.Client.prototype.onExportPDFShow=function(a){this.modal.onExportPDFShow(a)};netgis.Client.prototype.onExportPNGShow=function(a){this.modal.onExportPNGShow(a)};netgis.Client.prototype.onExportJPEGShow=function(a){this.modal.onExportJPEGShow(a)};netgis.Client.prototype.onExportGIFShow=function(a){this.modal.onExportGIFShow(a)};netgis.Client.prototype.onExportPDF=function(a){this.map.onExportPDF(a)};
netgis.Client.prototype.onExportPNG=function(a){this.map.onExportPNG(a)};netgis.Client.prototype.onExportJPEG=function(a){this.map.onExportJPEG(a)};netgis.Client.prototype.onExportGIF=function(a){this.map.onExportGIF(a)};netgis.Client.prototype.onLayerTreeImportClick=function(a){this.importServiceModal.show()};
netgis.Client.prototype.onImportFileTypeChange=function(a){a=this.importFileSelect.value;var b="*.*";console.info("File Type:",a);switch(a){case "geojson":b=".geojson,.json";break;case "gml":b=".gml,.xml";break;case "gpkg":b=".gpkg";break;case "shp":b="application/zip";break;case "spatialite":b=".sqlite"}this.importFileInput.setAttribute("accept",b)};
netgis.Client.prototype.onImportFileClick=function(a){if(a=this.importFileInput.files[0]){var b=this;switch(netgis.util.getFileExtension(a.name).toLowerCase()){case "geojson":console.info("GeoJSON detected:",a.name);var c=new FileReader;c.onload=function(a){a=JSON.parse(a.target.result);b.map.addEditFeaturesGeoJSON(a,!0);b.map.zoomGeoJSON(a);b.editFolder.classList.remove("netgis-hide")};c.readAsText(a);break;case "zip":console.info("Shapefile Zip detected:",a.name);c=new FileReader;c.onload=function(a){b.map.addEditFeaturesShapefile(a.target.result);
b.editFolder.classList.remove("netgis-hide")};c.readAsArrayBuffer(a);break;case "gml":console.info("GML detected:",a.name);c=new FileReader;c.onload=function(a){a=b.map.createLayerGML(a.target.result);b.map.addEditFeaturesFromLayer(a);b.editFolder.classList.remove("netgis-hide")};c.readAsText(a);break;case "sqlite":console.info("Spatialite detected:",a.name);c=new FileReader;c.onload=function(a){b.map.addEditFeaturesSpatialite(a.target.result);b.editFolder.classList.remove("netgis-hide")};c.readAsArrayBuffer(a);
break;case "gpkg":console.info("GeoPackage detected:",a.name),c=new FileReader,c.onload=function(a){b.map.addEditFeaturesGeopackage(a.target.result);b.editFolder.classList.remove("netgis-hide")},c.readAsArrayBuffer(a)}this.importModal.hide()}else alert("No file selected!")};
netgis.Client.prototype.addImportLayer=function(a,b){this.importCounter||(this.importCounter=0);var c=this.importCounter+1;c="import-"+c;this.importCounter+=1;this.layerTree.addCheckbox(this.importFolder,c,a);this.importFolder.classList.remove("netgis-hide");this.importLayers[c]=b;this.map.setLayerOrder(b,this.map.importLayerID);a=this.config.styles["import"];this.map.setLayerStyleSimple(b,a.fill,a.stroke,a.width);this.map.addLayer(c,b);this.layerTree.setItemChecked(c,!0);this.map.zoomLayer(c);this.importModal.hide()};
netgis.Client.prototype.onImportServiceClick=function(a){this.importServiceDetails.classList.add("netgis-hide");var b=this.importServiceInput.value;b=b.trim();if(!(1>b.length)){var c=b.indexOf("?");this.importServiceBaseURL=a=-1<c?b.substr(0,c):b;var d=["request=GetCapabilities"];if(-1<c)for(b=b.substr(c+1),b=b.split("&"),c=0;c<b.length;c++){var e=b[c];e=e.toLowerCase();-1<e.search("service")?d.push(e):-1<e.search("version")&&d.push(e)}a=a+"?"+d.join("&");-1===a.search("service=")?(netgis.util.request(a+
"&service=WMS",this.onImportServiceCapsResponse.bind(this)),netgis.util.request(a+"&service=WFS",this.onImportServiceCapsResponse.bind(this))):netgis.util.request(a,this.onImportServiceCapsResponse.bind(this))}};
netgis.Client.prototype.onImportServiceCapsResponse=function(a){var b=(new DOMParser).parseFromString(a,"text/xml").documentElement,c=this.importServiceLayerSelect;a=this.importServiceFormatSelect;for(var d=c.options.length-1;0<=d;d--)c.options.remove(d);for(d=a.options.length-1;0<=d;d--)a.options.remove(d);switch(b.nodeName){default:case "HTML":this.importServiceType=null;console.warn("could not detect wms or wfs service",b);break;case "WMS_Capabilities":case "WMT_MS_Capabilities":this.importServiceType=
"wms";b.getAttribute("version");d=b.getElementsByTagName("Service")[0];d=d.getElementsByTagName("Title")[0].textContent;this.importServiceNameInput.value=d;for(var e=b.getElementsByTagName("Layer"),f=[],g=0;g<e.length;g++){d=e[g];var h=d.getElementsByTagName("Name")[0].textContent,k=d.getElementsByTagName("Title")[0].textContent;f.push({name:h,title:k});d=document.createElement("option");d.text=k;d.value=h;c.options.add(d)}c=b.getElementsByTagName("GetMap")[0].getElementsByTagName("Format");b=[];
for(g=0;g<c.length;g++)d=c[g],e=d.textContent,b.push(e),d=document.createElement("option"),d.text=e,d.value=e,a.options.add(d);break;case "WFS_Capabilities":case "wfs:WFS_Capabilities":this.importServiceType="wfs";b.getAttribute("version");d=b.getElementsByTagName("ows:ServiceIdentification")[0];d=d.getElementsByTagName("ows:Title")[0].textContent;this.importServiceNameInput.value=d;e=b.getElementsByTagName("FeatureType");f=[];for(g=0;g<e.length;g++)d=e[g],h=d.getElementsByTagName("Name")[0].textContent,
k=d.getElementsByTagName("Title")[0].textContent,f.push({name:h,title:k}),d=document.createElement("option"),d.text=k,d.value=h,c.options.add(d);b=b.getElementsByTagName("ows:Operation");d=null;for(c=0;c<b.length;c++)if("GetFeature"===b[c].getAttribute("name")){d=b[c];break}b=null;if(d)for(d=d.getElementsByTagName("ows:Parameter"),c=0;c<d.length;c++)if(g=d[c],"outputFormat"===g.getAttribute("name")){c=g.getElementsByTagName("ows:Value");for(g=0;g<c.length;g++)d=c[g],e=d.textContent,d=document.createElement("option"),
d.text=e,d.value=e,a.options.add(d),-1<e.search("json")&&(b=e);break}b&&(a.value=b)}this.importServiceDetails.classList.remove("netgis-hide")};
netgis.Client.prototype.onImportServiceAccept=function(a){a=this.importServiceBaseURL;var b=this.importServiceNameInput.value,c=this.importServiceLayerSelect.value,d=this.importServiceFormatSelect.value;switch(this.importServiceType){case "wms":this.addImportLayer(b,this.map.createLayerWMS(a,c,d,!1));break;case "wfs":this.addImportLayer(b,this.map.createLayerWFS(a+"?",c,null,d))}};netgis.Client.prototype.onImportShow=function(a){this.importModal.show()};
netgis.Client.prototype.onExportShow=function(a){this.exportWidthInput.value=this.map.getWidth();this.exportHeightInput.value=this.map.getHeight();this.exportLandscapeInput.checked=this.exportWidthInput.value>this.exportHeightInput.value;this.toolboxPanel.hide();this.exportModal.show()};
netgis.Client.prototype.onExportFormatChange=function(a){"pdf"===this.exportFormatSelect.value?(this.exportPaddingInput.parentNode.classList.remove("netgis-hide"),this.exportLandscapeInput.parentNode.classList.remove("netgis-hide")):(this.exportPaddingInput.parentNode.classList.add("netgis-hide"),this.exportLandscapeInput.parentNode.classList.add("netgis-hide"))};
netgis.Client.prototype.onExportButtonClick=function(a){a=this.exportFormatSelect.value;var b=Number.parseInt(this.exportWidthInput.value),c=Number.parseInt(this.exportHeightInput.value),d=Number.parseInt(this.exportPaddingInput.value);this.map.exportImage(a,b,c,this.exportLandscapeInput.checked,d)};netgis=netgis||{};netgis.Controls=function(){this.initElements()};
netgis.Controls.prototype.initElements=function(){this.container=document.createElement("section");this.container.className="netgis-controls netgis-color-e netgis-text-a netgis-shadow netgis-round";this.zoomIn=this.createButton("<i class='fas fa-plus'></i>","Zoom +");this.zoomIn.addEventListener("click",this.onZoomInClick.bind(this));this.container.appendChild(this.zoomIn);this.zoomOut=this.createButton("<i class='fas fa-minus'></i>","Zoom -");this.zoomOut.addEventListener("click",this.onZoomOutClick.bind(this));
this.container.appendChild(this.zoomOut);this.zoomAll=this.createButton("<i class='fas fa-home'></i>","Zoom auf Anfangsausdehung");this.zoomAll.addEventListener("click",this.onZoomAllClick.bind(this));this.container.appendChild(this.zoomAll)};netgis.Controls.prototype.attach=function(a){a.appendChild(this.container)};netgis.Controls.prototype.createButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.innerHTML=a;c.title=b;c.className="netgis-hover-a";return c};
netgis.Controls.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-controls netgis-color-e netgis-text-a netgis-hover-a netgis-shadow netgis-round";var a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="<i class='fas fa-search-plus'></i>";a.title="Hineinzoomen";a.addEventListener("click",this.onZoomInClick.bind(this));this.root.appendChild(a);a=document.createElement("button");a.setAttribute("type","button");a.innerHTML="<i class='fas fa-search-minus'></i>";
a.title="Herauszoomen";a.addEventListener("click",this.onZoomOutClick.bind(this));this.root.appendChild(a);this.client.root.appendChild(this.root)};netgis.Controls.prototype.onZoomInClick=function(a){netgis.util.invoke(this.container,netgis.Events.CONTROLS_ZOOM,1)};netgis.Controls.prototype.onZoomOutClick=function(a){netgis.util.invoke(this.container,netgis.Events.CONTROLS_ZOOM,-1)};
netgis.Controls.prototype.onZoomAllClick=function(a){netgis.util.invoke(this.container,netgis.Events.CONTROLS_ZOOM_ALL,null)};netgis.Controls.prototype.onSettings=function(a){alert("TODO: settings dialog")};netgis=netgis||{};
netgis.Events=Object.freeze({PANEL_RESIZE:"panel-resize",PANEL_TOGGLE:"panel-toggle",LAYERS_TOGGLE:"layers-toggle",TOOLBOX_TOGGLE:"toolbox-toggle",CONTROLS_ZOOM:"controls-zoom",CONTROLS_ZOOM_ALL:"controls-zoom-all",MAP_FEATURE_ENTER:"map-feature-enter",MAP_FEATURE_HOVER:"map-feature-hover",MAP_FEATURE_CLICK:"map-feature-click",MAP_FEATURE_LEAVE:"map-feature-leave",PARCELS_RESET:"parcels-reset",PARCELS_FIELDS_RESPONSE:"parcels-fields-response",PARCELS_RESPONSE:"parcels-response",PARCELS_ITEM_ENTER:"parcels-item-enter",
PARCELS_ITEM_LEAVE:"parcels-item-leave",PARCELS_ITEM_CLICK:"parcels-item-click",PARCELS_ITEM_IMPORT_CLICK:"parcels-item-import-click",SNAP_TOGGLE:"snap-toggle",BUFFER_TOGGLE:"buffer-toggle",TRACING_TOGGLE:"tracing-toggle",IMPORT_SHOW:"import-show",EXPORT_SHOW:"export-show",CONTEXT_UPDATE:"CONTEXT_UPDATE",SET_MODE:"SET_MODE",LAYER_LIST_TOGGLE:"LAYER_LIST_TOGGLE",PANEL_SHOW:"PANEL_SHOW",PANEL_HIDE:"PANEL_HIDE",LAYER_SHOW:"LAYER_SHOW",LAYER_HIDE:"LAYER_HIDE",LAYER_CREATED:"LAYER_CREATED",MAP_ZOOM_WKT:"MAP_ZOOM_WKT",
MAP_SET_EXTENT:"MAP_SET_EXTENT",MAP_CHANGE_ZOOM:"MAP_CHANGE_ZOOM",MAP_UPDATE_STYLE:"MAP_UPDATE_STYLE",MAP_MODE_POINTS:"MAP_MODE_POINTS",MAP_MODE_LINES:"MAP_MODE_LINES",MAP_MODE_POLYGONS:"MAP_MODE_POLYGONS",EDIT_FEATURES_LOADED:"EDIT_FEATURES_LOADED",EDIT_FEATURES_CHANGE:"EDIT_FEATURES_CHANGE",SEARCH_PLACE_REQUEST:"SEARCH_PLACE_REQUEST",SEARCH_PLACE_RESPONSE:"SEARCH_PLACE_RESPONSE",PARCEL_SHOW_PREVIEW:"PARCEL_SHOW_PREVIEW",PARCEL_HIDE_PREVIEW:"PARCEL_HIDE_PREVIEW",BUFFER_CHANGE:"BUFFER_CHANGE",BUFFER_ACCEPT:"BUFFER_ACCEPT",
BUFFER_CANCEL:"BUFFER_CANCEL",DRAW_BUFFER_ON:"DRAW_BUFFER_ON",DRAW_BUFFER_OFF:"DRAW_BUFFER_OFF",DRAW_BUFFER_RADIUS_CHANGE:"DRAW_BUFFER_RADIUS_CHANGE",DRAW_BUFFER_SEGMENTS_CHANGE:"DRAW_BUFFER_SEGMENTS_CHANGE",SNAP_ON:"SNAP_ON",SNAP_OFF:"SNAP_OFF",TRACING_ON:"TRACING_ON",TRACING_OFF:"TRACING_OFF",IMPORT_SHAPEFILE_SHOW:"IMPORT_SHAPEFILE_SHOW",IMPORT_GEOJSON_SHOW:"IMPORT_GEOJSON_SHOW",IMPORT_GML_SHOW:"IMPORT_GML_SHOW",IMPORT_SPATIALITE_SHOW:"IMPORT_SPATIALITE_SHOW",IMPORT_GEOPACKAGE_SHOW:"IMPORT_GEOPACKAGE_SHOW",
IMPORT_SHAPEFILE:"IMPORT_SHAPEFILE",IMPORT_GEOJSON:"IMPORT_GEOJSON",IMPORT_GML:"IMPORT_GML",IMPORT_WKT:"IMPORT_WKT",IMPORT_SPATIALITE:"IMPORT_SPATIALITE",IMPORT_GEOPACKAGE:"IMPORT_GEOPACKAGE",EXPORT_PDF_SHOW:"EXPORT_PDF_SHOW",EXPORT_JPEG_SHOW:"EXPORT_JPEG_SHOW",EXPORT_PNG_SHOW:"EXPORT_PNG_SHOW",EXPORT_GIF_SHOW:"EXPORT_GIF_SHOW",EXPORT_PDF:"EXPORT_PDF",EXPORT_JPEG:"EXPORT_JPEG",EXPORT_PNG:"EXPORT_PNG",EXPORT_GIF:"EXPORT_GIF",EXPORT_BEGIN:"EXPORT_BEGIN",EXPORT_END:"EXPORT_END",ADD_SERVICE_SHOW:"ADD_SERVICE_SHOW",
ADD_SERVICE_WMS:"ADD_SERVICE_WMS",ADD_SERVICE_WFS:"ADD_SERVICE_WFS"});netgis=netgis||{};netgis.LayerTypes=Object.freeze({XYZ:"XYZ",OSM:"OSM",WMS:"WMS",WFS:"WFS",KML:"KML"});netgis=netgis||{};netgis.Map=function(){this.attribution=this.root=this.client=null};netgis.Map.prototype.load=function(){this.root=document.createElement("section");this.root.className="netgis-map";this.client.root.appendChild(this.root)};netgis=netgis||{};
netgis.MapOpenLayers=function(a){this.activeLayers={};this.projection=a.map.projection;this.config=a;this.mode=null;this.toolbars={};this.map=this.view=null;this.layers=[];this.interactions={};this.sketch=this.selected=this.hoverLayer=this.hoverFeature=this.parcelLayer=this.editLayer=this.snapFeatures=this.snap=null;this.editEventsSilent=!1;this.importLayerID=2E4;this.editLayerID=3E4;this.labelFont="4mm Verdana, sans-serif";this.drawBufferRadius=100;this.drawBufferSegments=3;this.initElements();this.initMap(a);
this.initStyles(a);this.initDefaultLayers();this.initInteractions();this.initEvents()};netgis.MapOpenLayers.prototype.initElements=function(){this.container=document.createElement("section");this.container.className="netgis-map"};netgis.MapOpenLayers.prototype.attach=function(a){a.appendChild(this.container)};netgis.MapOpenLayers.prototype.initEvents=function(){this.container.addEventListener("pointerleave",this.onPointerLeave.bind(this))};
netgis.MapOpenLayers.prototype.load=function(){netgis.Map.prototype.load.call(this);this.dropTarget=document.createElement("div");this.dropTarget.className="netgis-drop-target netgis-hide";this.dropTarget.innerHTML="Datei hier ablegen!";this.container.appendChild(this.dropTarget);this.container.addEventListener("dragenter",this.onDragEnter.bind(this));this.container.addEventListener("dragover",this.onDragEnter.bind(this));this.container.addEventListener("dragend",this.onDragLeave.bind(this));this.container.addEventListener("dragleave",
this.onDragLeave.bind(this));this.container.addEventListener("drop",this.onDragDrop.bind(this));this.initMap();this.initDefaultLayers();this.initInteractions();this.client.on(netgis.Events.CONTEXT_UPDATE,this.onContextUpdate.bind(this));this.client.on(netgis.Events.MAP_UPDATE_STYLE,this.onUpdateStyle.bind(this));this.client.on(netgis.Events.EDIT_FEATURES_LOADED,this.onEditFeaturesLoaded.bind(this));this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SNAP_ON,
this.onSnapOn.bind(this));this.client.on(netgis.Events.SNAP_OFF,this.onSnapOff.bind(this));this.client.on(netgis.Events.TRACING_ON,this.onTracingOn.bind(this));this.client.on(netgis.Events.TRACING_OFF,this.onTracingOff.bind(this));this.client.on(netgis.Events.LAYER_SHOW,this.onLayerShow.bind(this));this.client.on(netgis.Events.LAYER_HIDE,this.onLayerHide.bind(this));this.client.on(netgis.Events.MAP_ZOOM_WKT,this.onZoomWKT.bind(this));this.client.on(netgis.Events.MAP_SET_EXTENT,this.onSetExtent.bind(this));
this.client.on(netgis.Events.MAP_CHANGE_ZOOM,this.onChangeZoom.bind(this));this.client.on(netgis.Events.BUFFER_CHANGE,this.onBufferChange.bind(this));this.client.on(netgis.Events.BUFFER_ACCEPT,this.onBufferAccept.bind(this));this.client.on(netgis.Events.BUFFER_CANCEL,this.onBufferCancel.bind(this));this.client.on(netgis.Events.IMPORT_GEOJSON,this.onImportGeoJSON.bind(this));this.client.on(netgis.Events.IMPORT_GML,this.onImportGML.bind(this));this.client.on(netgis.Events.IMPORT_SHAPEFILE,this.onImportShapefile.bind(this));
this.client.on(netgis.Events.IMPORT_WKT,this.onImportWKT.bind(this));this.client.on(netgis.Events.IMPORT_SPATIALITE,this.onImportSpatialite.bind(this));this.client.on(netgis.Events.IMPORT_GEOPACKAGE,this.onImportGeopackage.bind(this));this.client.on(netgis.Events.EXPORT_PDF,this.onExportPDF.bind(this));this.client.on(netgis.Events.EXPORT_JPEG,this.onExportJPEG.bind(this));this.client.on(netgis.Events.EXPORT_PNG,this.onExportPNG.bind(this));this.client.on(netgis.Events.EXPORT_GIF,this.onExportGIF.bind(this));
this.client.on(netgis.Events.PARCEL_SHOW_PREVIEW,this.onParcelShowPreview.bind(this));this.client.on(netgis.Events.PARCEL_HIDE_PREVIEW,this.onParcelHidePreview.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WMS,this.onAddServiceWMS.bind(this));this.client.on(netgis.Events.ADD_SERVICE_WFS,this.onAddServiceWFS.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_ON,this.onDrawBufferOn.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_OFF,this.onDrawBufferOff.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,
this.onDrawBufferRadiusChange.bind(this));this.client.on(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,this.onDrawBufferSegmentsChange.bind(this))};
netgis.MapOpenLayers.prototype.initMap=function(a){"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));this.view=new ol.View({projection:a.map.projection,center:a.map.center,minZoom:a.map.minZoom,maxZoom:a.map.maxZoom,zoom:a.map.zoom});this.setPadding(0,0,0,0);this.map=new ol.Map({target:this.container,view:this.view,pixelRatio:1,moveTolerance:5,controls:[]});a.map.scalebar&&(this.scalebar=new ol.control.ScaleLine({bar:!0}),
this.map.addControl(this.scalebar));this.map.on("pointermove",this.onPointerMove.bind(this));this.map.on("click",this.onSingleClick.bind(this));this.map.on("movestart",this.onMoveStart.bind(this));this.map.on("moveend",this.onMoveEnd.bind(this));this.view.on("change:resolution",this.onChangeResolution.bind(this))};netgis.MapOpenLayers.prototype.initStyles=function(a){a=a.styles.select;this.hoverStyle=this.createStyle(a.fill,a.stroke,a.width);this.hoverStyle.setZIndex(1)};
netgis.MapOpenLayers.prototype.initDefaultLayers=function(){this.editLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),style:this.styleEdit.bind(this),zIndex:this.editLayerID});this.addLayer(netgis.Client.Layers.EDIT_LAYER,this.editLayer);this.previewLayer=new ol.layer.Vector({source:new ol.source.Vector({features:[]}),style:this.styleSketch.bind(this),zIndex:this.editLayerID+1E3});this.addLayer(netgis.Client.Layers.PREVIEW_LAYER,this.previewLayer);this.editEventsOn()};
netgis.MapOpenLayers.prototype.editEventsOn=function(){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))};netgis.MapOpenLayers.prototype.editEventsOff=function(){};
netgis.MapOpenLayers.prototype.initInteractions=function(){this.interactions[netgis.Modes.VIEW]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.PANNING]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.ZOOMING_IN]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.ZOOMING_OUT]=this.interactions[netgis.Modes.VIEW];this.interactions[netgis.Modes.DRAW_POINTS]=[new ol.interaction.Draw({type:"Point",source:this.editLayer.getSource(),
style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_POINTS][0].on("drawend",this.onDrawPointsEnd.bind(this));this.interactions[netgis.Modes.DRAW_LINES]=[new ol.interaction.Draw({type:"LineString",source:this.editLayer.getSource(),style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.DRAW_LINES][0].on("drawend",this.onDrawLinesEnd.bind(this));
this.interactions[netgis.Modes.DRAW_POLYGONS]=[new ol.interaction.Draw({type:"Polygon",source:this.editLayer.getSource(),style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURE_BEGIN]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.CUT_FEATURE_DRAW]=[new ol.interaction.Draw({type:"Polygon",style:this.styleSketch.bind(this)}),new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];
this.interactions[netgis.Modes.CUT_FEATURE_DRAW][0].on("drawend",this.onCutFeatureDrawEnd.bind(this));this.interactions[netgis.Modes.MODIFY_FEATURES]=[new ol.interaction.DragPan,new ol.interaction.Modify({source:this.editLayer.getSource(),deleteCondition:ol.events.condition.doubleClick,style:this.styleModify.bind(this)}),new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.MODIFY_FEATURES][0].on("modifyend",this.onModifyFeaturesEnd.bind(this));this.interactions[netgis.Modes.DELETE_FEATURES]=
[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.BUFFER_FEATURE_BEGIN]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.BUFFER_FEATURE_EDIT]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.snapFeatures=new ol.Collection;this.interactions[netgis.Modes.SEARCH_PLACE]=[new ol.interaction.DragPan,new ol.interaction.MouseWheelZoom];this.interactions[netgis.Modes.SEARCH_PARCEL]=this.interactions[netgis.Modes.VIEW]};
netgis.MapOpenLayers.prototype.addLayer=function(a,b){b&&(b.set("id",a),this.map.addLayer(b),this.activeLayers[a]=b)};netgis.MapOpenLayers.prototype.removeLayer=function(a){var b=this.activeLayers[a];b&&(this.map.removeLayer(b),delete this.activeLayers[a])};netgis.MapOpenLayers.prototype.createStyle=function(a,b,c){var d={};a&&(d.fill=new ol.style.Fill({color:a}));b&&(d.stroke=new ol.style.Stroke({color:b,width:c?c:3}));return new ol.style.Style(d)};
netgis.MapOpenLayers.prototype.setLayerStyle=function(a,b){a.setStyle?a.setStyle(b):console.warn("setting style on a non-vector layer",a,b)};netgis.MapOpenLayers.prototype.setLayerStyleSimple=function(a,b,c,d){this.setLayerStyle(a,this.createStyle(b,c,d))};netgis.MapOpenLayers.prototype.setLayerStyleEdit=function(a){a.setStyle(this.styleEdit.bind(this))};netgis.MapOpenLayers.prototype.setLayerOrder=function(a,b){a.setZIndex(Number.parseInt(b))};
netgis.MapOpenLayers.prototype.createLayer=function(a){var b=null;switch(a.type){case netgis.LayerTypes.XYZ:b=this.createLayerXYZ(a.url);break;case netgis.LayerTypes.OSM:b=this.createLayerOSM();break;case netgis.LayerTypes.WMS:b=this.createLayerWMS(a.url,a.name,a.format,a.tiled,a.username,a.password);break;case netgis.LayerTypes.WFS:b=this.createLayerWFS(a.url,a.name,this.projection,a.format,a.username,a.password),(a.fill||a.stroke||a.width)&&b.setStyle(this.createStyle(a.fill,a.stroke,a.width))}b&&
(a.minZoom&&b.setMinZoom(Number.parseFloat(a.minZoom)),a.maxZoom&&b.setMaxZoom(Number.parseFloat(a.maxZoom)),a.order&&b.setZIndex(Number.parseInt(a.order)));return b};netgis.MapOpenLayers.prototype.createLayerXYZ=function(a){return new ol.layer.Tile({source:new ol.source.XYZ({url:a,crossOrigin:"anonymous"})})};netgis.MapOpenLayers.prototype.createLayerOSM=function(){return new ol.layer.Tile({source:new ol.source.OSM})};
netgis.MapOpenLayers.prototype.createLayerWMS=function(a,b,c,d,e,f){a={url:a,params:{LAYERS:b,FORMAT:c?c:"image/png",TRANSPARENT:"true",VERSION:"1.1.1"},serverType:"mapserver",crossOrigin:"anonymous",hidpi:!1};e&&f&&(a.imageLoadFunction=function(a,b){var c=new XMLHttpRequest;c.open("GET",b);c.setRequestHeader("Authorization","Basic "+window.btoa(e+":"+f));c.onload=function(){a.getImage().src=b};c.send()});d?(d=new ol.source.TileWMS(a),d=new ol.layer.Tile({source:d})):(d=new ol.source.ImageWMS(a),
d=new ol.layer.Image({source:d}));return d};
netgis.MapOpenLayers.prototype.createLayerWFS=function(a,b,c,d,e,f){a+="service=WFS&version=1.1.0&request=GetFeature";c||(c=this.projection);d=d?netgis.util.replace(d," ","+"):"application/json; subtype=geojson";var g=new ol.source.Vector({format:new ol.format.GeoJSON,strategy:ol.loadingstrategy.bbox,loader:function(h,k,n,p,q){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");q()};l.onload=function(){if(200===l.status){var a=g.getFormat().readFeatures(l.responseText);g.clear();g.addFeatures(a);p(a)}else console.error("WFS Request Status",l.status),q()};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.MapOpenLayers.prototype.clearAll=function(){for(var a=0;a<this.layers.length;a++)this.map.removeLayer(this.layers[a]);this.layers=[];this.snapFeatures.clear()};netgis.MapOpenLayers.prototype.addFeature=function(a,b){a.getSource().addFeature(b)};netgis.MapOpenLayers.prototype.addEditFeature=function(a){this.editLayer.getSource().addFeature(a)};netgis.MapOpenLayers.prototype.addEditFeaturesFromLayer=function(a){a=a.getSource().getFeatures();this.addImportedFeatures(a)};
netgis.MapOpenLayers.prototype.addEditFeaturesGeoJSON=function(a,b){var c=new ol.format.GeoJSON;c.readProjection(a);a=b?c.readFeatures(a,{featureProjection:this.projection}):c.readFeatures(a);this.addImportedFeatures(a)};netgis.MapOpenLayers.prototype.addEditFeaturesShapefile=function(a){var b=this;shp(a).then(function(a){var c=new ol.format.GeoJSON;c.readProjection(a);a=c.readFeatures(a,{featureProjection:b.projection});b.addImportedFeatures(a)})};
netgis.MapOpenLayers.prototype.addEditFeaturesGeopackage=function(a){var b=this;a=new Uint8Array(a);window.GeoPackage.setSqljsWasmLocateFile(function(a){return b.config["import"].geopackageLibURL+a});window.GeoPackage.GeoPackageAPI.open(a).then(function(a){for(var c=[],e=new ol.format.GeoJSON,f=a.getFeatureTables(),g=0;g<f.length;g++)for(var h=a.queryForGeoJSONFeaturesInTable(f[g]),k=0;k<h.length;k++){var l=e.readGeometry(h[k].geometry,{featureProjection:b.projection});l=new ol.Feature({geometry:l});
c.push(l)}b.addImportedFeatures(c)})};
netgis.MapOpenLayers.prototype.addEditFeaturesSpatialite=function(a){var b=this;window.initSqlJs().then(function(c){var d=[],e=new Uint8Array(a);c=new c.Database(e);var f=c.exec("SELECT name FROM sqlite_schema WHERE type = 'table' \n\t\t\t\t\tAND name NOT LIKE 'sqlite_%' \n\t\t\t\t\tAND name NOT LIKE 'sql_%' \n\t\t\t\t\tAND name NOT LIKE 'idx_%' \n\t\t\t\t\tAND name NOT LIKE 'spatial_ref_sys%' \n\t\t\t\t\tAND name NOT LIKE 'spatialite_%' \n\t\t\t\t\tAND name NOT LIKE 'geometry_columns%' \n\t\t\t\t\tAND name NOT LIKE 'views_%' \n\t\t\t\t\tAND name NOT LIKE 'virts_%' \n\t\t\t\t\tAND name NOT LIKE 'SpatialIndex' \n\t\t\t\t\tAND name NOT LIKE 'ElementaryGeometries' \n\t\t\t\t;");e=
f[0].values;for(var g=0;g<e.length;g++){f=c.exec("SELECT * FROM "+e[g][0]);var h=f[0];f=null;for(var k=0;k<h.columns.length;k++){if("geometry"===h.columns[k].toLowerCase()){f=k;break}if("geom"===h.columns[k].toLowerCase()){f=k;break}}h=h.values;for(k=0;k<h.length;k++){var l=h[k][f],m=new Uint8Array(l.length-43-1+5);m[0]=l[1];m[1]=l[39];m[2]=l[40];m[3]=l[41];m[4]=l[42];for(var n=l.length-43-1,p=0;p<n;p++)m[5+p]=l[43+p];l=(new ol.format.WKB).readGeometry(m,{featureProjection:b.projection});d.push(new ol.Feature({geometry:l}))}}b.addImportedFeatures(d)})};
netgis.MapOpenLayers.prototype.createFeatureWKT=function(a,b){a=(new ol.format.WKT).readGeometry(a);b.geometry=a;return new ol.Feature(b)};netgis.MapOpenLayers.prototype.createFeatureJSON=function(a){return new ol.Feature(a)};netgis.MapOpenLayers.prototype.onUpdateStyle=function(a){a=new ol.style.Style({fill:new ol.style.Fill({color:a.polygon.fill}),stroke:new ol.style.Stroke({color:a.polygon.stroke,width:a.polygon.strokeWidth})});this.editLayer.setStyle(a)};
netgis.MapOpenLayers.prototype.styleEdit=function(a){var b=a.getGeometry(),c=this.hoverFeature===a,d=c?this.config.styles.select.fill:this.config.styles.editLayer.fill;a=c?this.config.styles.select.stroke:this.config.styles.editLayer.stroke;d=new ol.style.Style({image:new ol.style.Circle({radius:c?this.config.styles.select.pointRadius:this.config.styles.editLayer.pointRadius,fill:new ol.style.Fill({color:a})}),fill:new ol.style.Fill({color:d}),stroke:new ol.style.Stroke({color:a,width:this.config.styles.editLayer.strokeWidth})});
c&&d.setZIndex(1);b instanceof ol.geom.Polygon&&(b=b.getArea(),d.setText(new ol.style.Text({text:[netgis.util.formatArea(b,!0),"4mm sans-serif"],font:this.labelFont,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 d};
netgis.MapOpenLayers.prototype.styleSelect=function(a){var b=a.getGeometry();a=new ol.style.Style({image:new ol.style.Circle({radius:this.client.config.styles.select.pointRadius,fill:new ol.style.Fill({color:this.client.config.styles.select.stroke})}),fill:new ol.style.Fill({color:this.client.config.styles.select.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.select.stroke,width:this.client.config.styles.select.strokeWidth})});b instanceof ol.geom.Polygon&&(b=b.getArea(),a.setText(new ol.style.Text({text:[netgis.util.formatArea(b,
!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.client.config.styles.select.stroke}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]})));return a};
netgis.MapOpenLayers.prototype.styleModify=function(a){var b=new ol.style.Style({image:new ol.style.Circle({radius:this.config.styles.modify.pointRadius,fill:new ol.style.Fill({color:this.config.styles.modify.stroke})}),fill:new ol.style.Fill({color:this.config.styles.modify.fill}),stroke:new ol.style.Stroke({color:this.config.styles.modify.stroke,width:this.config.styles.modify.strokeWidth})}),c=new ol.style.Style({image:new ol.style.Circle({radius:this.config.styles.modify.pointRadius,fill:new ol.style.Fill({color:this.config.styles.modify.stroke})}),
geometry:this.getGeometryPoints(a)});a=a.getGeometry();a instanceof ol.geom.Polygon&&(a=a.getArea(),b.setText(new ol.style.Text({text:[netgis.util.formatArea(a,!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.config.styles.modify.stroke}),backgroundFill:new ol.style.Fill({color:"rgba( 255, 255, 255, 0.5 )"}),padding:[2,4,2,4]})));return[b,c]};
netgis.MapOpenLayers.prototype.styleSketch=function(a){var b=a.getGeometry(),c=new ol.style.Style({image:new ol.style.Circle({radius:this.config.styles.sketch.pointRadius,fill:new ol.style.Fill({color:this.config.styles.sketch.stroke})}),fill:new ol.style.Fill({color:this.config.styles.sketch.fill}),stroke:new ol.style.Stroke({color:this.config.styles.sketch.stroke,width:this.config.styles.sketch.strokeWidth})});b instanceof ol.geom.Polygon&&(b=b.getArea(),c.setText(new ol.style.Text({text:[netgis.util.formatArea(b,
!0),"4mm sans-serif"],font:this.labelFont,fill:new ol.style.Fill({color:this.config.styles.sketch.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:this.config.styles.sketch.pointRadius,fill:new ol.style.Fill({color:this.config.styles.sketch.stroke})}),geometry:this.getGeometryPoints(a)});return[c,a]};
netgis.MapOpenLayers.prototype.styleParcel=function(){return new ol.style.Style({fill:new ol.style.Fill({color:this.client.config.styles.parcel.fill}),stroke:new ol.style.Stroke({color:this.client.config.styles.parcel.stroke,width:this.client.config.styles.parcel.strokeWidth}),zIndex:99999})};netgis.MapOpenLayers.prototype.redrawVectorLayers=function(){this.map.getLayers().forEach(function(a,b,c){a instanceof ol.layer.Vector&&a.setStyle(a.getStyle())})};
netgis.MapOpenLayers.prototype.getGeometryPoints=function(a){var b=a.getGeometry();if(b instanceof ol.geom.LineString)return new ol.geom.MultiPoint(b.getCoordinates());if(b instanceof ol.geom.Polygon){a=[];b=b.getCoordinates();for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiPolygon){a=[];for(var f=b.getPolygons(),g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);
return new ol.geom.MultiPoint(a)}if(b instanceof ol.geom.MultiLineString){a=[];f=b.getPolygons();for(g=0;g<f.length;g++)for(b=f[g].getCoordinates(),c=0;c<b.length;c++)for(d=b[c],e=0;e<d.length;e++)a.push(d[e]);return new ol.geom.MultiPoint(a)}return b};netgis.MapOpenLayers.prototype.getActiveVectorLayers=function(){for(var a=[],b=this.map.getLayers().getArray(),c=this.layers,d=0;d<c.length;d++){var e=c[d];e instanceof ol.layer.Vector&&-1<b.indexOf(e)&&a.push(e)}return a};
netgis.MapOpenLayers.prototype.setMode=function(a){switch(this.mode){case netgis.Modes.BUFFER_FEATURE_EDIT:this.onBufferCancel(null);break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:var b=this.drawBufferOn;this.onDrawBufferOff(null);this.drawBufferOn=b;break;case netgis.Modes.MODIFY_FEATURES:this.editLayer.setStyle(this.styleEdit.bind(this))}this.container.classList.remove("netgis-cursor-draw");this.container.classList.remove("netgis-clickable");switch(a){case netgis.Modes.DRAW_POINTS:this.container.classList.add("netgis-cursor-draw");
this.updateSnapFeatures();if(this.drawBufferOn)this.onDrawBufferOn();break;case netgis.Modes.DRAW_LINES:this.container.classList.add("netgis-cursor-draw");this.updateSnapFeatures();if(this.drawBufferOn)this.onDrawBufferOn();break;case netgis.Modes.DRAW_POLYGONS:this.container.classList.add("netgis-cursor-draw");this.updateSnapFeatures();break;case netgis.Modes.MODIFY_FEATURES:this.editLayer.setStyle(this.styleModify.bind(this))}this.map.getInteractions().clear();(b=this.interactions[a])||(b=this.interactions[netgis.Modes.VIEW]);
for(var c=0;c<b.length;c++)this.map.addInteraction(b[c]);this.snap&&(a===netgis.Modes.DRAW_POINTS||a===netgis.Modes.DRAW_LINES||a===netgis.Modes.DRAW_POLYGONS)&&this.map.addInteraction(this.snap);this.mode=a};netgis.MapOpenLayers.prototype.getModeClassName=function(a){a=a.toLowerCase();a=netgis.util.replace(a,"_","-");return"netgis-mode-"+a};netgis.MapOpenLayers.prototype.setSnapOn=function(){this.snap=new ol.interaction.Snap({features:this.snapFeatures});this.map.addInteraction(this.snap);this.snapFeatures.changed()};
netgis.MapOpenLayers.prototype.setSnapOff=function(){this.snap&&(this.map.removeInteraction(this.snap),this.snap=null)};netgis.MapOpenLayers.prototype.setTracingOn=function(){var a=new ol.source.Vector({features:this.snapFeatures});this.tracing=new ol.interaction.Draw({type:"Polygon",source:this.editLayer.getSource(),style:this.styleSketch.bind(this),trace:!0,traceSource:a});a=this.interactions[netgis.Modes.DRAW_POLYGONS];a[0].setActive(!1);a.push(this.tracing);this.setMode(this.mode)};
netgis.MapOpenLayers.prototype.setTracingOff=function(){var a=this.interactions[netgis.Modes.DRAW_POLYGONS];a[0].setActive(!0);a.splice(a.indexOf(this.tracing),1);this.setMode(this.mode)};netgis.MapOpenLayers.prototype.addSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.push(a[b])};netgis.MapOpenLayers.prototype.removeSnapLayer=function(a){a=a.getSource().getFeatures();for(var b=0;b<a.length;b++)this.snapFeatures.remove(a[b])};
netgis.MapOpenLayers.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.MapOpenLayers.prototype.zoomExtent=function(a,b,c,d){a=ol.proj.fromLonLat([a,b],this.projection);c=ol.proj.fromLonLat([c,d],this.projection);this.view.fit([a[0],a[1],c[0],c[1]])};netgis.MapOpenLayers.prototype.zoomWKT=function(a){a=(new ol.format.WKT).readGeometry(a);this.view.fit(a,{duration:300})};
netgis.MapOpenLayers.prototype.zoomGeoJSON=function(a){a=(new ol.format.GeoJSON).readFeatures(a,{});for(var b=a[0].getGeometry().getExtent(),c=1;c<a.length;c++)ol.extent.extend(b,a[c].getGeometry().getExtent());this.view.fit(b,{duration:300})};netgis.MapOpenLayers.prototype.zoomLayer=function(a){var b=this.activeLayers[a];b||(b=a);b.getSource&&b.getSource().getExtent&&(a=b.getSource().getExtent())&&Number.isFinite(a[0])&&this.view.fit(a,{duration:300})};
netgis.MapOpenLayers.prototype.zoomFeature=function(a){this.view.fit(a.getGeometry(),{duration:300})};netgis.MapOpenLayers.prototype.zoom=function(a){this.view.animate({zoom:this.view.getZoom()+a,duration:200})};netgis.MapOpenLayers.prototype.zoomLevel=function(a){this.view.animate({zoom:a,center:this.view.getCenter(),duration:300})};netgis.MapOpenLayers.prototype.zoomAll=function(){var a=this.config.map;this.view.animate({zoom:a.zoom,center:a.center,duration:500})};
netgis.MapOpenLayers.prototype.setPadding=function(a,b,c,d){this.view.padding=[a+40,b+40,c+40,d+40]};netgis.MapOpenLayers.prototype.onSnapOn=function(a){this.setSnapOn()};netgis.MapOpenLayers.prototype.onSnapOff=function(a){this.setSnapOff()};netgis.MapOpenLayers.prototype.onTracingOn=function(a){this.setTracingOn()};netgis.MapOpenLayers.prototype.onTracingOff=function(a){this.setTracingOff()};
netgis.MapOpenLayers.prototype.onLayerShow=function(a){if(a=this.layers[a.id])this.map.addLayer(a),a instanceof ol.layer.Vector&&this.addSnapLayer(a)};netgis.MapOpenLayers.prototype.onLayerHide=function(a){if(a=this.layers[a.id])this.map.removeLayer(a),a instanceof ol.layer.Vector&&this.removeSnapLayer(a)};
netgis.MapOpenLayers.prototype.onContextUpdate=function(a){this.clearAll();if(a=a.bbox){if(netgis.util.isDefined(this.client.config.map)&&netgis.util.isDefined(this.client.config.map.projection)){var b=ol.proj.fromLonLat([a[0],a[1]],this.client.config.map.projection);var c=ol.proj.fromLonLat([a[2],a[3]],this.client.config.map.projection)}else b=ol.proj.fromLonLat([a[0],a[1]]),c=ol.proj.fromLonLat([a[2],a[3]]);a[0]=b[0];a[1]=b[1];a[2]=c[0];a[3]=c[1];this.view.fit(a)}};
netgis.MapOpenLayers.prototype.onAddServiceWMS=function(a){var b=this.createLayerWMS(a.url,a.name,a.format);b.setZIndex(a.id);this.layers[a.id]=b};netgis.MapOpenLayers.prototype.onAddServiceWFS=function(a){var b=this.createLayerWFS(a.url,a.name,this.client.config.map.projection,a.format);b.setZIndex(a.id);this.layers[a.id]=b};netgis.MapOpenLayers.prototype.onSetMode=function(a){this.setMode(a)};
netgis.MapOpenLayers.prototype.onSetExtent=function(a){var b=ol.proj.fromLonLat([a.minx,a.miny],this.client.config.map.projection);a=ol.proj.fromLonLat([a.maxx,a.maxy],this.client.config.map.projection);this.view.fit([b[0],b[1],a[0],a[1]])};netgis.MapOpenLayers.prototype.onChangeZoom=function(a){this.view.animate({zoom:this.view.getZoom()+a,duration:200})};netgis.MapOpenLayers.prototype.onZoomWKT=function(a){a=(new ol.format.WKT).readGeometry(a);this.view.fit(a,{duration:300,padding:[40,40,40,40]})};
netgis.MapOpenLayers.prototype.onPointerMove=function(a){var b=a.pixel;a=a.coordinate;var c=null,d=null;this.map.forEachFeatureAtPixel(b,function(a,b){if(b){if(b.get("id")&&netgis.util.isString(b.get("id"))&&-1!==b.get("id").search("import-"))return!1;c=a;d=b;return!0}});switch(this.mode){default:return!0;case netgis.Modes.PARCEL_SELECT:case netgis.Modes.DELETE_FEATURES:case netgis.Modes.CUT_FEATURE_BEGIN:case netgis.Modes.BUFFER_FEATURE_BEGIN:break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:return this.updateDrawBufferPreview(),
!0}c!==this.hoverFeature&&(this.hoverFeature&&this.featureLeave(this.hoverFeature,this.hoverLayer,b,a),c&&this.featureEnter(c,d,b,a),this.redrawVectorLayers(),this.hoverFeature=c,this.hoverLayer=d);c&&this.featureHover(c,d,b,a)};netgis.MapOpenLayers.prototype.onPointerLeave=function(a){this.hoverFeature&&(this.featureLeave(this.hoverFeature,this.hoverLayer,[a.offsetX,a.offsetY],null),this.hoverLayer=this.hoverFeature=null)};
netgis.MapOpenLayers.prototype.featureEnter=function(a,b,c,d){if(b){this.container.classList.add("netgis-clickable");var e=!1;b.get("id")===netgis.Client.Layers.EDIT_LAYER&&(e=!0);b.get("id")===netgis.Client.Layers.PARCEL_DISTRICTS&&(e=!0);b.get("id")===netgis.Client.Layers.PARCEL_FIELDS&&(e=!0);b.get("id")===netgis.Client.Layers.PARCEL_FEATURES&&(e=!0);e&&a.setStyle(this.hoverStyle);netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_ENTER,{pixel:c,coords:d,layer:b.get("id"),properties:a.getProperties()})}};
netgis.MapOpenLayers.prototype.featureHover=function(a,b,c,d){};netgis.MapOpenLayers.prototype.featureLeave=function(a,b,c,d){b&&(this.container.classList.remove("netgis-clickable"),b.get("id")!==netgis.Client.Layers.EDIT_LAYER&&a.setStyle(null),netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_LEAVE,{pixel:c,coords:d,layer:b.get("id"),properties:a.getProperties()}))};
netgis.MapOpenLayers.prototype.findFeature=function(a,b,c){if(a=this.activeLayers[a]){a=a.getSource().getFeatures();for(var d=null,e=0;e<a.length;e++){var f=a[e];if(f.get(b)===c){d=f;break}}return d}};netgis.MapOpenLayers.prototype.setFeatureHover=function(a,b){a.setStyle(b?this.hoverStyle:null)};
netgis.MapOpenLayers.prototype.onPointerMove_01=function(a){a=a.pixel;var b=this.hoverFeature,c=this;switch(this.mode){case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.updateDrawBufferPreview()}b=null;this.map.forEachFeatureAtPixel(a,function(a,e){e===c.editLayer&&(b=a);return!0});b!==this.hoverFeature&&this.redrawVectorLayers();this.hoverFeature=b};
netgis.MapOpenLayers.prototype.onSingleClick=function(a){switch(this.mode){default:this.hoverFeature&&this.hoverLayer&&(a={pixel:a.pixel,coords:a.coordinate,layer:this.hoverLayer.get("id"),id:this.hoverFeature.getId(),properties:this.hoverFeature.getProperties()},netgis.util.invoke(this.container,netgis.Events.MAP_FEATURE_CLICK,a));break;case netgis.Modes.DELETE_FEATURES:this.hoverFeature&&(this.editLayer.getSource().removeFeature(this.hoverFeature),this.featureLeave(this.hoverFeature,this.editLayer),
this.hoverFeature=null,netgis.util.invoke(this.container,netgis.Events.SET_MODE,netgis.Modes.VIEW));break;case netgis.Modes.CUT_FEATURE_BEGIN:this.hoverFeature&&(this.selected=this.hoverFeature,netgis.util.invoke(this.container,netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_DRAW));break;case netgis.Modes.BUFFER_FEATURE_BEGIN:this.hoverFeature&&(this.selected=this.hoverFeature,netgis.util.invoke(this.container,netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_EDIT))}};
netgis.MapOpenLayers.prototype.onMoveStart=function(a){};netgis.MapOpenLayers.prototype.onMoveEnd=function(a){};netgis.MapOpenLayers.prototype.onChangeResolution=function(a){};
netgis.MapOpenLayers.prototype.onCutFeatureDrawEnd=function(a){var b=a.feature;if(a=this.selected){var c=new jsts.io.OL3Parser,d=c.read(a.getGeometry());b=c.read(b.getGeometry());d=d.difference(b);c=c.write(d);c=new ol.Feature({geometry:c});d=this.editLayer.getSource();d.removeFeature(a);d.addFeature(c);this.selected=c}this.editEventsSilent=!0;this.splitMultiPolygons(this.editLayer);this.editEventsSilent=!1;this.updateEditOutput();netgis.util.invoke(this.container,netgis.Events.SET_MODE,netgis.Modes.VIEW)};
netgis.MapOpenLayers.prototype.onModifyFeaturesEnd=function(a){this.updateEditOutput();this.updateEditArea()};netgis.MapOpenLayers.prototype.createBufferFeature=function(a,b,c){a=this.createBufferGeometry(a,b,c);return new ol.Feature({geometry:a})};netgis.MapOpenLayers.prototype.createBufferGeometry=function(a,b,c){var d=new jsts.io.OL3Parser;a=d.read(a).buffer(b,c);return d.write(a)};
netgis.MapOpenLayers.prototype.onBufferChange=function(a){var b=this.editLayer.getSource(),c=this.selected;this.sketch&&b.removeFeature(this.sketch);c&&(a=this.createBufferFeature(c.getGeometry(),a.radius,a.segments),b.addFeature(a),this.sketch=a)};netgis.MapOpenLayers.prototype.onBufferAccept=function(a){this.selected&&this.sketch&&this.editLayer.getSource().removeFeature(this.selected);this.selected=this.sketch=null};
netgis.MapOpenLayers.prototype.onBufferCancel=function(a){this.sketch&&(this.editLayer.getSource().removeFeature(this.sketch),this.sketch=null);this.selected=null};netgis.MapOpenLayers.prototype.onDrawPointsEnd=function(a){var b=this.previewLayer.getSource().getFeatures()[0];if(b){var c=this.editLayer.getSource();c.addFeature(b.clone());window.setTimeout(function(){c.removeFeature(a.feature)},10)}};
netgis.MapOpenLayers.prototype.onDrawLinesEnd=function(a){var b=this.previewLayer.getSource().getFeatures()[0];if(b){var c=this.editLayer.getSource();c.addFeature(b.clone());window.setTimeout(function(){c.removeFeature(a.feature)},10)}};netgis.MapOpenLayers.prototype.onDrawBufferOn=function(a){a=this.createBufferFeature(new ol.geom.Point(this.config.map.center),this.drawBufferRadius,this.drawBufferSegments);this.previewLayer.getSource().addFeature(a);this.drawBufferOn=!0};
netgis.MapOpenLayers.prototype.onDrawBufferOff=function(a){this.previewLayer.getSource().clear();this.drawBufferOn=!1};netgis.MapOpenLayers.prototype.onDrawBufferRadiusChange=function(a){this.drawBufferRadius=a;this.updateDrawBufferPreview()};netgis.MapOpenLayers.prototype.onDrawBufferSegmentsChange=function(a){this.drawBufferSegments=a;this.updateDrawBufferPreview()};
netgis.MapOpenLayers.prototype.updateDrawBufferPreview=function(){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.MapOpenLayers.prototype.onEditLayerAdd=function(a){this.updateEditLayerItem();this.updateEditOutput();this.snapFeatures.push(a.feature)};
netgis.MapOpenLayers.prototype.onEditLayerRemove=function(a){this.updateEditOutput();this.snapFeatures.remove(a.feature)};netgis.MapOpenLayers.prototype.onEditLayerChange=function(a){this.updateEditOutput()};
netgis.MapOpenLayers.prototype.updateEditOutput=function(){var a=this.editLayer.getSource().getFeatures(),b=this.projection,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;this.editEventsSilent||netgis.util.invoke(this.container,netgis.Events.EDIT_FEATURES_CHANGE,c)};
netgis.MapOpenLayers.prototype.updateEditLayerItem=function(){var a=this.editLayerID;this.activeLayers[a]||(this.activeLayers[a]=this.editLayer,netgis.util.invoke(this.container,netgis.Events.LAYER_CREATED,{id:a,title:"Zeichnung",checked:!0,folder:"draw"}))};netgis.MapOpenLayers.prototype.updateEditArea=function(){};
netgis.MapOpenLayers.prototype.onEditFeaturesLoaded=function(a){var b=this;console.info("Edit Features Loaded:",a);window.setTimeout(function(){b.addLayer("import",b.createLayerGeoJSON(a,!0))},10)};netgis.MapOpenLayers.prototype.onDragEnter=function(a){a.preventDefault();this.dropTarget.classList.remove("netgis-hide");return!1};netgis.MapOpenLayers.prototype.onDragLeave=function(a){this.dropTarget.classList.add("netgis-hide");return!1};
netgis.MapOpenLayers.prototype.onDragDrop=function(a){console.info("Drag Drop");this.dropTarget.classList.add("netgis-hide");a.preventDefault();a=a.dataTransfer.files[0];var b=new FileReader;b.onload=this.onDragLoad.bind(this);console.log("File:",a);b.readAsArrayBuffer(a);return!1};netgis.MapOpenLayers.prototype.onDragLoad=function(a){console.log("On Load:",a.target);this.loadShape(a.target.result)};netgis.MapOpenLayers.prototype.loadShape=function(a){var b=this;shp(a).then(function(a){b.onShapeLoad(a)})};
netgis.MapOpenLayers.prototype.onShapeLoad=function(a){console.info("Shapefile To Geojson:",a);a=(new ol.format.GeoJSON({dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})).readFeatures(a);this.importLayer.getSource().addFeatures(a);this.view.fit(this.importLayer.getSource().getExtent(),{})};netgis.MapOpenLayers.prototype.onImportGeoJSON=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGeoJSON(b,a.target.result)};d.readAsText(a)};
netgis.MapOpenLayers.prototype.onImportGML=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGML(b,a.target.result)};d.readAsText(a)};netgis.MapOpenLayers.prototype.onImportShapefile=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerShapefile(b,a.target.result)};d.readAsArrayBuffer(a)};
netgis.MapOpenLayers.prototype.onImportSpatialite=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerSpatialite(b,a.target.result)};d.readAsArrayBuffer(a)};netgis.MapOpenLayers.prototype.onImportGeopackage=function(a){var b=a.name,c=this,d=new FileReader;d.onload=function(a){c.createLayerGeopackage(b,a.target.result)};d.readAsArrayBuffer(a)};
netgis.MapOpenLayers.prototype.createLayerGeoJSON=function(a,b){var c=new ol.format.GeoJSON,d=c.readProjection(a);a=b?c.readFeatures(a,{featureProjection:this.projection}):c.readFeatures(a);d=d.getCode();switch(d){case "EPSG:3857":case "EPSG:4326":case this.projection:break;default:console.warn("Unsupported Import Projection:",d)}return new ol.layer.Vector({source:new ol.source.Vector({features:a})})};
netgis.MapOpenLayers.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);e.geometry=f;f=new ol.Feature(e);c.push(f)}return new ol.layer.Vector({source:new ol.source.Vector({features:c})})};netgis.MapOpenLayers.prototype.createLayerVector=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})});a&&b.setZIndex(a);return b};
netgis.MapOpenLayers.prototype.createLayerGML=function(a){console.warn("GML support is experimental!");var b=[];a=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("gml:featureMember");for(var c=0;c<a.length;c++){for(var d={},e=a[c].children[0],f=0;f<e.attributes.length;f++){var g=e.attributes[f];d[g.nodeName]=g.nodeValue}for(f=0;f<e.children.length;f++)if(g=e.children[f],"ogr:geometryProperty"!==g.nodeName){var h=g.nodeName.split(":");d[h[h.length-1]]=g.innerHTML}e=e.getElementsByTagName("ogr:geometryProperty")[0].children[0];
(f=e.getAttribute("srsName"))&&"EPSG:4326"!==f&&f!==this.projection&&console.warn("Unsupported Import Projection:",f);switch(e.nodeName){case "gml:Polygon":d.geometry=this.gmlParsePolygon(e,f);break;case "gml:MultiPolygon":d.geometry=this.gmlParseMultiPolygon(e,f)}d=new ol.Feature(d);b.push(d)}return new ol.layer.Vector({source:new ol.source.Vector({features:b})})};
netgis.MapOpenLayers.prototype.gmlParsePolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:LinearRing");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:coordinates")[0].innerHTML;c.push(this.gmlParseCoordinates(e,b))}return new ol.geom.Polygon(c)};
netgis.MapOpenLayers.prototype.gmlParseMultiPolygon=function(a,b){var c=[];a=a.getElementsByTagName("gml:polygonMember");for(var d=0;d<a.length;d++){var e=a[d].getElementsByTagName("gml:Polygon")[0];c.push(this.gmlParsePolygon(e,b))}return new ol.geom.MultiPolygon(c)};netgis.MapOpenLayers.prototype.gmlParseCoordinates=function(a,b){a=a.split(" ");for(var c=0;c<a.length;c++){a[c]=a[c].split(",");for(var d=0;d<a[c].length;d++)a[c][d]=Number.parseFloat(a[c][d]);b&&(a[c]=ol.proj.transform(a[c],b,this.projection))}return a};
netgis.MapOpenLayers.prototype.createLayerShapefile=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;shp(a).then(function(a){var d=new ol.format.GeoJSON;d.readProjection(a);a=d.readFeatures(a,{featureProjection:c.projection});b.getSource().addFeatures(a)});return b};
netgis.MapOpenLayers.prototype.createLayerSpatialite=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;window.initSqlJs().then(function(d){var e=[],f=new Uint8Array(a);d=new d.Database(f);var g=d.exec("SELECT name FROM sqlite_schema WHERE type = 'table' \n\t\t\t\t\tAND name NOT LIKE 'sqlite_%' \n\t\t\t\t\tAND name NOT LIKE 'sql_%' \n\t\t\t\t\tAND name NOT LIKE 'idx_%' \n\t\t\t\t\tAND name NOT LIKE 'spatial_ref_sys%' \n\t\t\t\t\tAND name NOT LIKE 'spatialite_%' \n\t\t\t\t\tAND name NOT LIKE 'geometry_columns%' \n\t\t\t\t\tAND name NOT LIKE 'views_%' \n\t\t\t\t\tAND name NOT LIKE 'virts_%' \n\t\t\t\t\tAND name NOT LIKE 'SpatialIndex' \n\t\t\t\t\tAND name NOT LIKE 'ElementaryGeometries' \n\t\t\t\t;");
f=g[0].values;for(var h=0;h<f.length;h++){g=d.exec("SELECT * FROM "+f[h][0]);var k=g[0];g=null;for(var l=0;l<k.columns.length;l++){if("geometry"===k.columns[l].toLowerCase()){g=l;break}if("geom"===k.columns[l].toLowerCase()){g=l;break}}k=k.values;for(l=0;l<k.length;l++){var m=k[l][g],n=new Uint8Array(m.length-43-1+5);n[0]=m[1];n[1]=m[39];n[2]=m[40];n[3]=m[41];n[4]=m[42];for(var p=m.length-43-1,q=0;q<p;q++)n[5+q]=m[43+q];m=(new ol.format.WKB).readGeometry(n,{featureProjection:c.projection});e.push(new ol.Feature({geometry:m}))}}b.getSource().addFeatures(e)});
return b};
netgis.MapOpenLayers.prototype.createLayerGeopackage=function(a){var b=new ol.layer.Vector({source:new ol.source.Vector({features:[]})}),c=this;a=new Uint8Array(a);window.GeoPackage.setSqljsWasmLocateFile(function(a){return c.config["import"].geopackageLibURL+a});window.GeoPackage.GeoPackageAPI.open(a).then(function(a){for(var d=[],f=new ol.format.GeoJSON,g=a.getFeatureTables(),h=0;h<g.length;h++)for(var k=a.queryForGeoJSONFeaturesInTable(g[h]),l=0;l<k.length;l++){var m=f.readGeometry(k[l].geometry,{featureProjection:c.projection});
m=new ol.Feature({geometry:m});d.push(m)}b.getSource().addFeatures(d)});return b};netgis.MapOpenLayers.prototype.addImportedFeatures=function(a){this.editLayer.getSource().addFeatures(a);this.updateSnapFeatures();if(0<a.length){for(var b=a[0].getGeometry().getExtent(),c=1;c<a.length;c++)ol.extent.extend(b,a[c].getGeometry().getExtent());this.view.fit(b,{duration:300})}};netgis.MapOpenLayers.prototype.onImportWKT=function(a){a=(new ol.format.WKT).readGeometry(a);a=new ol.Feature({geometry:a});this.addImportedFeatures([a])};
netgis.MapOpenLayers.prototype.onExportPDF=function(a){this.exportImage("pdf",a.resx,a.resy,a.mode,a.margin)};netgis.MapOpenLayers.prototype.onExportJPEG=function(a){this.exportImage("jpeg",a.resx,a.resy)};netgis.MapOpenLayers.prototype.onExportPNG=function(a){this.exportImage("png",a.resx,a.resy)};netgis.MapOpenLayers.prototype.onExportGIF=function(a){this.exportImage("gif",a.resx,a.resy)};
netgis.MapOpenLayers.prototype.onParcelShowPreview=function(a){a=(new ol.format.WKT).readGeometry(a.geom);a=new ol.Feature({geometry:a});this.parcelLayer.getSource().clear();this.parcelLayer.getSource().addFeature(a)};netgis.MapOpenLayers.prototype.onParcelHidePreview=function(a){this.parcelLayer.getSource().clear()};netgis.MapOpenLayers.prototype.getWidth=function(){return this.map.getSize()[0]};netgis.MapOpenLayers.prototype.getHeight=function(){return this.map.getSize()[1]};
netgis.MapOpenLayers.prototype.exportImage=function(a,b,c,d,e){netgis.util.invoke(this.container,netgis.Events.EXPORT_BEGIN,null);var f=this,g=this.container,h=this.map,k=this.config,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 p=n.getContext("2d");p.webkitImageSmoothingEnabled=!1;p.mozImageSmoothingEnabled=!1;p.imageSmoothingEnabled=!1;Array.prototype.forEach.call(document.querySelectorAll(".ol-layer canvas"),function(a){if(0<a.width){var b=a.parentNode.style.opacity;p.globalAlpha=""===b?1:Number(b);b=a.style.transform.match(/^matrix\(([^\(]*)\)$/)[1].split(",").map(Number);CanvasRenderingContext2D.prototype.setTransform.apply(p,b);p.drawImage(a,
0,0)}});p.drawImage(l,0,0);p.fillStyle="#fff";p.fillRect(0,n.height-30,140,30);p.fillStyle="#000";p.font="4mm sans-serif";p.fillText(netgis.util.getTimeStamp(),10,n.height-10);var q=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.export.defaultFilename+".pdf"});window.open(n,"_blank");break;case "jpeg":window.navigator.msSaveBlob?window.navigator.msSaveBlob(n.msToBlob(),k.export.defaultFilename+".jpg"):(q.setAttribute("download",k.export.defaultFilename+".jpg"),q.setAttribute("href",n.toDataURL("image/jpeg",1)),q.click());
break;case "png":window.navigator.msSaveBlob?window.navigator.msSaveBlob(n.msToBlob(),k.export.defaultFilename+".png"):(q.setAttribute("download",k.export.defaultFilename+".png"),q.setAttribute("href",n.toDataURL("image/png",1)),q.click());break;case "gif":q.setAttribute("download",k.export.defaultFilename+".gif"),v=new GIF({workerScript:k.export.gifWebWorker,quality:1}),v.addFrame(n),v.on("finished",function(a){q.setAttribute("href",window.URL.createObjectURL(a));q.click()}),v.render()}h.setTarget(g);
g.removeChild(m);netgis.util.invoke(f.container,netgis.Events.EXPORT_END,null)});h.renderSync()};l.src=k.export.logo};netgis.MapOpenLayers.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=netgis||{};netgis.Menu=function(){this.root=this.client=null;this.sections=[]};
netgis.Menu.prototype.load=function(){this.root=document.createElement("header");this.root.className="netgis-menu netgis-color-a netgis-shadow";var a=document.createElement("div");this.root.appendChild(a);var b=this.createButton('<i class="fab fa-buffer"></i><span>Inhalte</span>',!0);b.addEventListener("click",this.onToggleClick.bind(this));a.appendChild(b);!0===this.client.editable&&(b=this.createButton('<i class="fas fa-tools"></i><span>Werkzeuge</span>',!0),b.addEventListener("click",this.onToolboxClick.bind(this)),
a.appendChild(b));b=this.createButton('<i class="fas fa-vector-square"></i><span>Flurst\u00fccke</span>',!0);b.addEventListener("click",this.onSearchParcelClick.bind(this));a.appendChild(b);b=this.createButton('<i class="fas fa-search"></i><span>Suche</span>',!0);b.addEventListener("click",this.onSearchPlaceClick.bind(this));a.appendChild(b);this.client.editable&&(a=this.createMenu('<i class="fas fa-caret-down"></i>Zeichnen').getElementsByTagName("ul")[0],a.appendChild(this.createMenuItem('<i class="fas fa-map-marker-alt"></i>Punkte',
this.onDrawPointClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-minus"></i>Linien',this.onDrawLineClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-vector-square"></i>Polygone',this.onDrawPolygonClick.bind(this))),a=this.createMenu('<i class="fas fa-caret-down"></i>Bearbeiten').getElementsByTagName("ul")[0],a.appendChild(this.createMenuItem('<i class="fas fa-cut"></i>Ausschneiden',this.onCutFeatureClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-arrows-alt"></i>Verschieben',
this.onModifyFeaturesClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-eraser"></i>L\u00f6schen',this.onDeleteFeaturesClick.bind(this))),a.appendChild(this.createMenuItem('<i class="far fa-dot-circle"></i>Puffern',this.onBufferFeatureClick.bind(this))),a=this.createMenu('<i class="fas fa-caret-down"></i>Import').getElementsByTagName("ul")[0],a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GeoJSON',this.onImportGeoJSONClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GML',
this.onImportGMLClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>Shapefile',this.onImportShapefileClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>Spatialite',this.onImportSpatialiteClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GeoPackage',this.onImportGeopackageClick.bind(this))),a=this.createMenu('<i class="fas fa-caret-down"></i>Export').getElementsByTagName("ul")[0],a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>PDF',
this.onExportPDFClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>JPEG',this.onExportJPEGClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>PNG',this.onExportPNGClick.bind(this))),a.appendChild(this.createMenuItem('<i class="fas fa-file"></i>GIF',this.onExportGIFClick.bind(this))));this.client.root.appendChild(this.root)};
netgis.Menu.prototype.createButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-color-a netgis-hover-c";b&&(c.className+=" netgis-right");c.innerHTML=a;return c};
netgis.Menu.prototype.createMenu=function(a){var b=document.createElement("div");b.className="netgis-dropdown";var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-primary netgis-hover-primary";c.innerHTML=a;b.appendChild(c);a=document.createElement("ul");a.className="netgis-dropdown-content netgis-dialog netgis-shadow";b.appendChild(a);return b};
netgis.Menu.prototype.createMenuItem=function(a,b){var c=document.createElement("li");c.className="netgis-hover-light";var d=document.createElement("button");d.setAttribute("type","button");d.innerHTML=a;d.addEventListener("click",b);c.appendChild(d);return c};netgis.Menu.prototype.onToggleClick=function(a){netgis.util.invoke(this.root,netgis.Events.LAYERS_TOGGLE)};netgis.Menu.prototype.onDrawPointClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POINTS)};
netgis.Menu.prototype.onDrawLineClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_LINES)};netgis.Menu.prototype.onDrawPolygonClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DRAW_POLYGONS)};netgis.Menu.prototype.onCutFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_BEGIN)};netgis.Menu.prototype.onModifyFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.MODIFY_FEATURES)};
netgis.Menu.prototype.onDeleteFeaturesClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.DELETE_FEATURES)};netgis.Menu.prototype.onBufferFeatureClick=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_BEGIN)};netgis.Menu.prototype.onSearchPlaceClick=function(a){netgis.util.invoke(this.root,netgis.SearchPlace.Events.TOGGLE)};netgis.Menu.prototype.onSearchParcelClick=function(a){netgis.util.invoke(this.root,netgis.SearchParcel.Events.TOGGLE)};
netgis.Menu.prototype.onToolboxClick=function(a){netgis.util.invoke(this.root,netgis.Events.TOOLBOX_TOGGLE)};netgis.Menu.prototype.onSearchDataClick=function(a){alert("TODO: data search interface")};netgis.Menu.prototype.onImportOWSClick=function(a){alert("TODO: ows import interface, try setting url parameter '?ows=<url>'")};netgis.Menu.prototype.onImportShapefileClick=function(a){this.client.invoke(netgis.Events.IMPORT_SHAPEFILE_SHOW,null)};
netgis.Menu.prototype.onImportGeoJSONClick=function(a){this.client.invoke(netgis.Events.IMPORT_GEOJSON_SHOW,null)};netgis.Menu.prototype.onImportKMLClick=function(a){alert("TODO: kml import interface")};netgis.Menu.prototype.onImportGMLClick=function(a){this.client.invoke(netgis.Events.IMPORT_GML_SHOW,null)};netgis.Menu.prototype.onImportSpatialiteClick=function(a){this.client.invoke(netgis.Events.IMPORT_SPATIALITE_SHOW,null)};
netgis.Menu.prototype.onImportGeopackageClick=function(a){this.client.invoke(netgis.Events.IMPORT_GEOPACKAGE_SHOW,null)};netgis.Menu.prototype.onExportPDFClick=function(a){this.client.invoke(netgis.Events.EXPORT_PDF_SHOW,null)};netgis.Menu.prototype.onExportJPEGClick=function(a){this.client.invoke(netgis.Events.EXPORT_JPEG_SHOW,null)};netgis.Menu.prototype.onExportPNGClick=function(a){this.client.invoke(netgis.Events.EXPORT_PNG_SHOW,null)};
netgis.Menu.prototype.onExportGIFClick=function(a){this.client.invoke(netgis.Events.EXPORT_GIF_SHOW,null)};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.attach=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",PANNING:"PANNING",ZOOMING_IN:"ZOOMING_IN",ZOOMING_OUT:"ZOOMING_OUT",DRAW_POINTS:"DRAW_POINTS",DRAW_LINES:"DRAW_LINES",DRAW_POLYGONS:"DRAW_POLYGONS",CUT_FEATURE_BEGIN:"CUT_FEATURE_BEGIN",CUT_FEATURE_DRAW:"CUT_FEATURE_DRAW",MODIFY_FEATURES:"MODIFY_FEATURES",DELETE_FEATURES:"DELETE_FEATURES",BUFFER_FEATURE_BEGIN:"BUFFER_FEATURE_BEGIN",BUFFER_FEATURE_EDIT:"BUFFER_FEATURE_EDIT",SEARCH_PLACE:"SEARCH_PLACE",SEARCH_PARCEL:"SEARCH_PARCEL",PARCEL_SELECT:"PARCEL_SELECT",IMPORT:"IMPORT",
EXPORT:"EXPORT"});netgis=netgis||{};
netgis.OWS=function(){return{read:function(a,b){var c={layers:[],folders:[]};netgis.util.isDefined(a.properties)&&(c.bbox=a.properties.bbox);a=a.features;for(var d=0;d<a.length;d++){var e=a[d];if("Feature"===e.type){var f=e.properties;f=f.folder;var g=!1;for(e=0;e<c.folders.length;e++)if(c.folders[e].id===f){g=!0;break}if(!g){e=f.split("/");f=[];for(g=0;g<e.length;g++){var h=e[g];0<h.length&&f.push(h)}var k=-1;for(g=0;g<f.length;g++){h=f[g];var l="/"+f.slice(0,g+1).join("/"),m=!1;for(e=0;e<c.folders.length;e++)if(c.folders[e].path===
l){k=e;m=!0;break}m||(e=c.folders.length,c.folders.push({title:h,parent:k,path:l}),k=e)}}}}for(d=0;d<a.length;d++)if(e=a[d],"Feature"===e.type){f=e.properties;g=-1;for(e=0;e<c.folders.length;e++)if(c.folders[e].path===f.folder){g=e;break}e=f.offerings;for(h=0;h<e.length;h++)switch(k=e[h],l=k.operations,k.code){case "http://www.opengis.net/spec/owc-geojson/1.0/req/wms":c.layers.push({folder:g,type:netgis.LayerTypes.WMS,url:l[0].href,title:f.title,attribution:f.rights,active:f.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/xyz":k=
l[0];c.layers.push({folder:g,type:netgis.LayerTypes.XYZ,url:k.href,title:f.title,attribution:f.rights,active:f.active});break;case "http://www.opengis.net/spec/owc-geojson/1.0/req/osm":k=l[0],c.layers.push({folder:g,type:netgis.LayerTypes.XYZ,url:k.href,title:f.title,attribution:f.rights,active:f.active})}}b.invoke(netgis.Events.CONTEXT_UPDATE,c)}}}();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.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)};netgis.Panel.prototype.attach=function(a){a.appendChild(this.container)};
netgis.Panel.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.Panel.prototype.show=function(){this.container.classList.add("netgis-show");netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{panel:this,visible:!0})};
netgis.Panel.prototype.hide=function(){this.container.classList.remove("netgis-show");netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{panel:this,visible:!1})};netgis.Panel.prototype.toggle=function(){this.container.classList.toggle("netgis-show");netgis.util.invoke(this.container,netgis.Events.PANEL_TOGGLE,{panel:this,visible:this.container.classList.contains("netgis-show")})};netgis.Panel.prototype.visible=function(){return this.container.classList.contains("netgis-show")};
netgis.Panel.prototype.width=function(){return this.container.getBoundingClientRect().width};netgis.Panel.prototype.onHeaderClick=function(a){this.hide()};netgis.Panel.prototype.onResize=function(a){this.container.classList.contains("netgis-show")&&(a=this.container.getBoundingClientRect(),netgis.util.invoke(this.container,netgis.Events.PANEL_RESIZE,{width:a.width}))};netgis=netgis||{};netgis.SearchParcel=function(a,b){this.client=b;this.config=a;this.initElements();this.initEvents()};netgis.SearchParcel.Events=Object.freeze({TOGGLE:"search-parcel-toggle"});
netgis.SearchParcel.prototype.initElements=function(){this.container=document.createElement("section");this.container.className="netgis-search-parcel";var a=document.createElement("section");this.top=a;this.container.appendChild(a);var b=this.createInput("Gemarkungsname:");b.style.position="relative";a.appendChild(b);this.nameInput=b.children[0];this.nameInput.setAttribute("title","ENTER: Ausw\u00e4hlen, ESCAPE: Zur\u00fccksetzen");this.nameInput.addEventListener("keyup",this.onInputNameKey.bind(this));
this.nameLoader=document.createElement("div");this.nameLoader.className="netgis-loader netgis-text-primary netgis-hide";this.nameLoader.innerHTML="<i class='fas fa-spinner'></i>";b.appendChild(this.nameLoader);this.nameList=document.createElement("ul");a.appendChild(this.nameList);b=this.createInput("Gemarkungsnummer:");this.districtInput=b.children[0];a.appendChild(b);b=this.createInput("Flurnummer:");this.fieldInput=b.children[0];this.fieldInput.addEventListener("keyup",this.onInputFieldKey.bind(this));
a.appendChild(b);b=this.createInput("<span>Flurst\u00fccksnummer (Z\u00e4hler/Nenner):</span>");this.parcelInputA=b.children[1];this.parcelInputA.style.width="48%";this.parcelInputB=this.parcelInputA.cloneNode(!0);this.parcelInputB.style.marginLeft="4%";b.appendChild(this.parcelInputB);a.appendChild(b);b=document.createElement("button");b.setAttribute("type","button");b.addEventListener("click",this.onParcelSearchClick.bind(this));b.className="netgis-color-a netgis-hover-c";b.innerHTML="Flurst\u00fccke suchen";
b.style.marginTop="4mm";a.appendChild(b);b=document.createElement("section");b.className="netgis-hide";this.bottom=b;this.container.appendChild(b);var c=document.createElement("button");c.className="netgis-button netgis-clip-text netgis-color-c";c.innerHTML="<span>Flurst\u00fccke</span> <span></span><i class='netgis-icon fas fa-times'></i>";c.setAttribute("type","button");c.addEventListener("click",this.onBottomHeaderClick.bind(this));b.appendChild(c);this.parcelCount=c.getElementsByTagName("span")[1];
this.parcelInfo=document.createElement("p");this.parcelTable=this.createTable(";Flur;Z\u00e4hler;Nenner;FKZ;Fl\u00e4che (qm)".split(";"));this.parcelTable.classList.add("netgis-hide");this.parcelTable.style.position="absolute";this.parcelTable.style.width="100%";this.parcelTable.style.top="12mm";this.parcelTable.style.bottom="0mm";this.parcelTable.style.margin="0mm";this.parcelTable.style.overflow="auto";b.appendChild(this.parcelTable);this.parcelList=this.parcelTable.getElementsByTagName("tbody")[0];
this.parcelReset=document.createElement("button");this.parcelReset.setAttribute("type","button");this.parcelReset.addEventListener("click",this.onParcelResetClick.bind(this));this.parcelReset.className="netgis-color-a netgis-hover-c";this.parcelReset.innerHTML="Zur\u00fccksetzen";this.parcelReset.style.marginTop="4mm";a.appendChild(this.parcelReset);var d=this;window.setTimeout(function(){d.reset()},50)};netgis.SearchParcel.prototype.initEvents=function(){this.resizeObserver=(new ResizeObserver(this.onTopResize.bind(this))).observe(this.top)};
netgis.SearchParcel.prototype.attach=function(a){a.appendChild(this.container)};netgis.SearchParcel.prototype.createInput=function(a){var b=document.createElement("label");b.className="netgis-hover-text-primary";b.innerHTML=a;a=document.createElement("input");a.setAttribute("type","text");b.appendChild(a);return b};
netgis.SearchParcel.prototype.createNameItem=function(a){var b=document.createElement("li"),c=document.createElement("button");c.setAttribute("type","button");c.addEventListener("click",this.onNameItemClick.bind(this));c.className="netgis-color-e netgis-hover-a netgis-text-a netgis-hover-text-e";c.innerHTML=a;b.appendChild(c);return b};
netgis.SearchParcel.prototype.createTable=function(a){var b=document.createElement("div");b.className="netgis-table-wrapper";var c=document.createElement("table");b.appendChild(c);var d=document.createElement("thead");c.appendChild(d);var e=document.createElement("tr");e.className="netgis-color-d netgis-shadow";d.appendChild(e);for(d=0;d<a.length;d++){var f=document.createElement("th");f.innerHTML=a[d];e.appendChild(f)}a=document.createElement("tbody");c.appendChild(a);return b};
netgis.SearchParcel.prototype.createParcelItem=function(a,b,c,d,e,f,g){var h=document.createElement("tr");h.className="netgis-hover-light netgis-hover-text-primary";h.setAttribute("title","Klicken zum zoomen");h.setAttribute("data-id",d);h.setAttribute("data-field",a);h.setAttribute("data-parcel-a",b);h.setAttribute("data-parcel-b",c);h.setAttribute("data-bbox",f);h.setAttribute("data-geom",g);h.addEventListener("pointerenter",this.onParcelEnter.bind(this));h.addEventListener("pointerleave",this.onParcelLeave.bind(this));
h.addEventListener("click",this.onParcelClick.bind(this));f=document.createElement("td");h.appendChild(f);this.client.editable&&(g=document.createElement("button"),g.setAttribute("type","button"),g.setAttribute("title","Geometrie \u00fcbernehmen"),g.addEventListener("click",this.onParcelImportClick.bind(this)),g.className="netgis-text-primary netgis-hover-primary",g.innerHTML="<i class='fas fa-paste'></i>",f.appendChild(g));f=document.createElement("td");f.innerHTML=a;h.appendChild(f);a=document.createElement("td");
a.innerHTML=b;h.appendChild(a);b=document.createElement("td");b.innerHTML=c;h.appendChild(b);c=document.createElement("td");c.innerHTML=d;h.appendChild(c);d=document.createElement("td");d.innerHTML=e;h.appendChild(d);return h};
netgis.SearchParcel.prototype.reset=function(){this.hideBottom();this.nameLoader.classList.add("netgis-hide");this.nameInput.value="";this.districtInput.value="";this.fieldInput.value="";this.parcelInputA.value="";this.parcelInputB.value="";this.nameList.innerHTML="";this.parcelInfo.innerHTML="";this.parcelList.innerHTML="";this.parcelTable.classList.add("netgis-hide");this.parcelReset.classList.add("netgis-hide");this.parcelCount.innerHTML="";var a=this;window.setTimeout(function(){a.top.scrollTop=
0;a.parcelTable.scrollTop=0},10);netgis.util.invoke(this.container,netgis.Events.PARCELS_RESET,null)};netgis.SearchParcel.prototype.onInputNameKey=function(a){switch(a.keyCode){case 13:this.selectFirstName();break;case 27:this.reset();break;default:this.requestName(this.nameInput.value.trim())}};
netgis.SearchParcel.prototype.requestName=function(a){this.nameDebounce&&window.clearTimeout(this.nameDebounce);if(0!==a.length){var b=this.config.searchParcel.nameURL;b=netgis.util.replace(b,"{q}",window.encodeURIComponent(a));this.nameDebounce=window.setTimeout(this.onInputNameDebounce.bind(this,b),200);this.nameLoader.classList.remove("netgis-hide")}};netgis.SearchParcel.prototype.onInputNameDebounce=function(a){netgis.util.request(a,this.onInputNameResponse.bind(this))};
netgis.SearchParcel.prototype.onInputNameResponse=function(a){this.nameLoader.classList.add("netgis-hide");this.nameList.innerHTML="";if("{"===a.charAt(0)||"["===a.charAt(0)){a=JSON.parse(a);for(var b=0;b<a.data.length;b++){var c=a.data[b],d=this.createNameItem(c.gmk_name);d.getElementsByTagName("button")[0].setAttribute("data-id",c.gmk_gmn);this.nameList.appendChild(d)}}};
netgis.SearchParcel.prototype.onNameItemClick=function(a){a=a.target;var b=a.getAttribute("data-id");this.nameInput.value=a.innerHTML;this.nameList.innerHTML="";this.districtInput.value=b;this.requestFieldsGeom(b)};
netgis.SearchParcel.prototype.requestFieldsGeom=function(a){var b=this.config.searchParcel.fields_service,c=b.url;c=c+"service=WFS&version=1.0.0&request=GetFeature&outputFormat=application/json; subtype=geojson&typename="+b.name;c=c+"&filter=<Filter><PropertyIsEqualTo><PropertyName>"+(b.filter_property+"</PropertyName>");netgis.util.request(c+("<Literal>"+a+"</Literal></PropertyIsEqualTo></Filter>"),this.onFieldsGeomResponse.bind(this))};
netgis.SearchParcel.prototype.onFieldsGeomResponse=function(a){a=JSON.parse(a);netgis.util.invoke(this.container,netgis.Events.PARCELS_FIELDS_RESPONSE,{geojson:a})};netgis.SearchParcel.prototype.selectFirstName=function(){var a=this.nameList.getElementsByTagName("button");0<a.length&&a[0].click()};netgis.SearchParcel.prototype.setDistrict=function(a,b){this.nameInput.value=a;this.districtInput.value=b;this.requestFieldsGeom(b)};
netgis.SearchParcel.prototype.setFieldNumber=function(a){this.fieldInput.value=a;this.onParcelSearchClick()};netgis.SearchParcel.prototype.setParcelNumber=function(a,b){this.parcelInputA.value=a;this.parcelInputB.value=b;this.onParcelSearchClick()};netgis.SearchParcel.prototype.showBottom=function(){this.top.classList.add("netgis-resize-bottom");this.top.style.height="50%";this.top.style.bottom="auto";this.bottom.classList.remove("netgis-hide")};
netgis.SearchParcel.prototype.hideBottom=function(){this.top.classList.remove("netgis-resize-bottom");this.top.style.height="auto";this.top.style.bottom="0mm";this.bottom.classList.add("netgis-hide")};netgis.SearchParcel.prototype.onInputFieldKey=function(a){switch(a.keyCode){case 13:this.onParcelSearchClick()}};netgis.SearchParcel.prototype.onParcelSearchClick=function(a){this.requestParcel(this.districtInput.value.trim(),this.fieldInput.value.trim(),this.parcelInputA.value.trim(),this.parcelInputB.value.trim())};
netgis.SearchParcel.prototype.requestParcel=function(a,b,c,d){var e=this.config.searchParcel.parcelURL;e=netgis.util.replace(e,"{district}",a?a:"");e=netgis.util.replace(e,"{field}",b?b:"");e=netgis.util.replace(e,"{parcelA}",c?c:"");e=netgis.util.replace(e,"{parcelB}",d?d:"");this.parcelTable.classList.add("netgis-hide");this.parcelList.innerHTML="";this.parcelInfo.innerHTML="Suche Flurst\u00fccke...";netgis.util.request(e,this.onParcelResponse.bind(this))};
netgis.SearchParcel.prototype.onParcelResponse=function(a){a=JSON.parse(a);this.parcelCount.innerHTML="("+a.count+")";if(0===a.count)this.parcelInfo.innerHTML=a.Info;else{for(var b=0;b<a.data.length;b++){var c=a.data[b];c=this.createParcelItem(c.fln,c.fsn_zae,c.fsn_nen,c.fsk,c.flaeche,c.bbox,c.geometry);this.parcelList.appendChild(c)}this.parcelTable.classList.remove("netgis-hide");this.showBottom();netgis.util.invoke(this.container,netgis.Events.PARCELS_RESPONSE,{parcels:a.data})}this.parcelReset.classList.remove("netgis-hide");
this.container.classList.contains("netgis-hide")||this.parcelTable.scrollIntoView()};netgis.SearchParcel.prototype.onParcelEnter=function(a){a=a.target;var b=a.getAttribute("data-geom");a={id:a.getAttribute("data-id"),field:a.getAttribute("data-field"),parcelA:a.getAttribute("data-parcel-a"),parcelB:a.getAttribute("data-parcel-b"),geom:b};netgis.util.invoke(this.container,netgis.Events.PARCELS_ITEM_ENTER,a)};
netgis.SearchParcel.prototype.onParcelLeave=function(a){netgis.util.invoke(this.container,netgis.Events.PARCELS_ITEM_LEAVE,{id:a.target.getAttribute("data-id")})};netgis.SearchParcel.prototype.onParcelClick=function(a){netgis.util.invoke(this.container,netgis.Events.PARCELS_ITEM_CLICK,{id:a.currentTarget.getAttribute("data-id")})};
netgis.SearchParcel.prototype.onParcelImportClick=function(a){a.stopPropagation();var b=a.currentTarget.parentElement.parentElement;a=b.getAttribute("data-id");b=b.getAttribute("data-geom");netgis.util.invoke(this.container,netgis.Events.PARCELS_ITEM_IMPORT_CLICK,{id:a,geom:b})};netgis.SearchParcel.prototype.onParcelResetClick=function(a){this.reset()};
netgis.SearchParcel.prototype.onSetMode=function(a){a===netgis.Modes.SEARCH_PARCEL&&this.container.classList.contains("netgis-hide")?this.container.classList.remove("netgis-hide"):this.container.classList.add("netgis-hide")};netgis.SearchParcel.prototype.onLayerListToggle=function(a){this.container.classList.add("netgis-hide")};
netgis.SearchParcel.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.SearchParcel.prototype.onBottomHeaderClick=function(a){this.reset()};netgis=netgis||{};"use strict";netgis=netgis||{};netgis.SearchPlace=function(a){this.config=a;this.debounce=400;this.initElements();this.initEvents()};netgis.SearchPlace.Events=Object.freeze({TOGGLE:"toggle",SELECT:"select"});
netgis.SearchPlace.prototype.initElements=function(){var a=document.createElement("div");a.className="netgis-search-place netgis-color-e netgis-shadow";this.input=document.createElement("input");this.input.setAttribute("type","text");this.input.setAttribute("placeholder","Suche...");a.appendChild(this.input);this.list=document.createElement("ul");a.appendChild(this.list);this.closer=document.createElement("button");this.closer.setAttribute("type","button");this.closer.className="netgis-button";this.closer.innerHTML=
"<i class='fas fa-times'></i>";this.closer.addEventListener("click",this.onCloserClick.bind(this));a.appendChild(this.closer);this.container=a};
netgis.SearchPlace.prototype.initEvents=function(){this.input.addEventListener("change",this.onInputChange.bind(this));this.input.addEventListener("keydown",this.onInputKeyDown.bind(this));this.input.addEventListener("keyup",this.onInputKeyUp.bind(this));this.input.addEventListener("click",this.onInputClick.bind(this));this.container.addEventListener("focusout",this.onFocusOut.bind(this))};netgis.SearchPlace.prototype.attach=function(a){a.appendChild(this.container)};
netgis.SearchPlace.prototype.toggle=function(){this.container.classList.toggle("netgis-show");this.container.classList.contains("netgis-show")?this.input.focus():this.list.classList.add("netgis-hide")};
netgis.SearchPlace.prototype.requestSearch=function(a){if(!this.lastQuery||this.lastQuery!==a){this.lastQuery=a;var b=this.config.search.url;b=netgis.util.replace(b,"{q}",window.encodeURIComponent(a));b=netgis.util.replace(b,"{epsg}",4326);b=window.encodeURI(b);this.lastRequest=netgis.util.request(b,this.onSearchResponse.bind(this))}};
netgis.SearchPlace.prototype.createResult=function(a,b,c,d,e){var f=document.createElement("li"),g=document.createElement("button");g.className="netgis-button netgis-clip-text netgis-color-e netgis-hover-a";g.innerHTML=a;g.setAttribute("type","button");g.setAttribute("title",a);g.setAttribute("data-minx",b);g.setAttribute("data-miny",c);g.setAttribute("data-maxx",d);g.setAttribute("data-maxy",e);g.addEventListener("click",this.onResultClick.bind(this));f.appendChild(g);return f};
netgis.SearchPlace.prototype.onSearchResponse=function(a){a=JSON.parse(a);console.info("Search Response:",a);this.list.innerHTML="";this.list.classList.remove("netgis-hide");if(a.geonames){a=a.geonames;for(var b=0;b<a.length;b++){var c=a[b],d=this.createResult(c.title,Number.parseFloat(c.minx),Number.parseFloat(c.miny),Number.parseFloat(c.maxx),Number.parseFloat(c.maxy));d.children[0].setAttribute("data-title",c.title);this.list.appendChild(d)}}};
netgis.SearchPlace.prototype.onInputKeyDown=function(a){if(13===a.keyCode)return this.list.classList.remove("netgis-hide"),a.preventDefault(),!1};netgis.SearchPlace.prototype.onInputKeyUp=function(a){switch(a.keyCode){case 13:break;case 27:this.toggle();break;default:this.onInputChange()}};netgis.SearchPlace.prototype.onInputChange=function(a){this.timeout&&window.clearTimeout(this.timeout);this.timeout=window.setTimeout(this.onInputTimeout.bind(this),this.debounce)};
netgis.SearchPlace.prototype.onInputTimeout=function(){var a=this.input.value;a=a.trim();0<a.length&&this.requestSearch(a)};netgis.SearchPlace.prototype.onInputClick=function(a){this.list.classList.toggle("netgis-hide")};netgis.SearchPlace.prototype.onFocusOut=function(a){a=a.relatedTarget;a!==this.input&&a!==this.list&&(a&&a.parentNode===this.list||a&&a.parentNode.parentNode===this.list||this.list.classList.add("netgis-hide"))};
netgis.SearchPlace.prototype.onResultClick=function(a){a=a.currentTarget;var b=Number.parseFloat(a.getAttribute("data-minx")),c=Number.parseFloat(a.getAttribute("data-miny")),d=Number.parseFloat(a.getAttribute("data-maxx")),e=Number.parseFloat(a.getAttribute("data-maxy")),f=a.getAttribute("data-title");netgis.util.invoke(a,netgis.SearchPlace.Events.SELECT,{minx:b,miny:c,maxx:d,maxy:e,title:f})};
netgis.SearchPlace.prototype.onCloserClick=function(a){this.toggle();this.list.innerHTML="";this.input.value=""};netgis=netgis||{};
netgis.SLD=function(){return{read:function(a,b){var c={};a=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("NamedLayer");for(var d=0;d<a.length;d++){var e=a[d],f=e.getElementsByTagName("se:Name")[0].innerHTML;console.info("Layer:",f);e=e.getElementsByTagName("se:FeatureTypeStyle");for(f=0;f<e.length;f++)for(var g=e[f].getElementsByTagName("se:Rule"),h=0;h<g.length;h++){var k=g[h],l=k.getElementsByTagName("se:Name")[0].innerHTML;console.info("Rule:",l);l=k.getElementsByTagName("se:PolygonSymbolizer")[0];k=
l.getElementsByTagName("se:Fill")[0];l=l.getElementsByTagName("se:Stroke")[0];c.polygon={fill:k.querySelector("[name='fill']").innerHTML,stroke:l.querySelector("[name='stroke']").innerHTML,strokeWidth:Number.parseFloat(l.querySelector("[name='stroke-width']").innerHTML)}}}console.info("SLD:",c);b.invoke(netgis.Events.MAP_UPDATE_STYLE,c);return c}}}();netgis=netgis||{};netgis.Tabs=function(a){this.initElements(a);this.initEvents();this.setActiveTab(0)};
netgis.Tabs.prototype.initElements=function(a){this.container=document.createElement("div");this.container.className="netgis-tabs";this.header=document.createElement("div");this.header.className="netgis-header";this.header.style.background="orange";this.container.appendChild(this.header);this.content=document.createElement("div");this.content.className="netgis-content";this.container.appendChild(this.content);for(var b=0;b<a.length;b++){var c=document.createElement("button");c.setAttribute("type",
"button");c.addEventListener("click",this.onHeaderButtonClick.bind(this));c.className="netgis-button netgis-color-d";c.innerHTML=a[b];this.header.appendChild(c);c=document.createElement("section");c.className="netgis-color-e netgis-form";this.content.appendChild(c)}};netgis.Tabs.prototype.initEvents=function(){};netgis.Tabs.prototype.attach=function(a){a.appendChild(this.container)};
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"),f.classList.remove("netgis-hide")):(e.classList.remove("netgis-color-e"),e.classList.remove("netgis-text-a"),e.classList.remove("netgis-bar-a"),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.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.Toolbar=function(){this.client=null;this.toolbars={};this.searchValue=""};
netgis.Toolbar.prototype.load=function(){var a=this.client.config;this.root=document.createElement("section");this.root.className="netgis-toolbars";if(this.client.editable){var b=1E3,c=3;netgis.util.isDefined(a.tools)&&(netgis.util.isDefined(a.tools.buffer.defaultRadius)&&(b=a.tools.buffer.defaultRadius),netgis.util.isDefined(a.tools.buffer.defaultSegments)&&(c=a.tools.buffer.defaultSegments));this.toolbars[netgis.Modes.DRAW_POINTS]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_POINTS],
this.createToolbarButton('<i class="fas fa-times"></i><span>Punkte zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarCheckbox("Puffern",this.onDrawBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarInput("Radius (Meter):",b,this.onDrawBufferRadiusChange.bind(this)));
this.append(this.toolbars[netgis.Modes.DRAW_POINTS],this.createToolbarInput("Segmente:",c,this.onDrawBufferSegmentsChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POINTS]);this.toolbars[netgis.Modes.DRAW_LINES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarButton('<i class="fas fa-times"></i><span>Linien zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarCheckbox("Einrasten",
this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarCheckbox("Puffern",this.onDrawBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarInput("Radius (Meter):",b,this.onDrawBufferRadiusChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_LINES],this.createToolbarInput("Segmente:",c,this.onDrawBufferSegmentsChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_LINES]);this.showDrawBufferOptions(!1);
this.toolbars[netgis.Modes.DRAW_POLYGONS]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarButton('<i class="fas fa-times"></i><span>Polygone zeichnen:</span>',this.onToolbarClose.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarCheckbox("Einrasten",this.onSnapChange.bind(this)));this.append(this.toolbars[netgis.Modes.DRAW_POLYGONS],this.createToolbarCheckbox("Tracing",this.onTracingChange.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DRAW_POLYGONS]);
this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]=this.createToolbar();this.append(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature zum Ausschneiden w\u00e4hlen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_BEGIN]);this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]=this.createToolbar();this.append(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW],this.createToolbarButton('<i class="fas fa-times"></i><span>Fl\u00e4che zum Ausschneiden zeichnen:</span>',
this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.CUT_FEATURE_DRAW]);this.toolbars[netgis.Modes.MODIFY_FEATURES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.MODIFY_FEATURES],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature-Eckpunkte verschieben:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.MODIFY_FEATURES]);this.toolbars[netgis.Modes.DELETE_FEATURES]=this.createToolbar();this.append(this.toolbars[netgis.Modes.DELETE_FEATURES],
this.createToolbarButton('<i class="fas fa-times"></i><span>Features l\u00f6schen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.DELETE_FEATURES]);this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]=this.createToolbar();this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature zum Puffern w\u00e4hlen:</span>',this.onToolbarClose.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_BEGIN]);
this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT]=this.createToolbar();this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarButton('<i class="fas fa-times"></i><span>Feature puffern:</span>',this.onBufferCancel.bind(this)));this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarInput("Radius (Meter):",b,this.onBufferChange.bind(this)));this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarInput("Segmente:",c,this.onBufferChange.bind(this)));
this.append(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT],this.createToolbarButton('<i class="fas fa-check"></i><span>OK</span>',this.onBufferAccept.bind(this)));a=this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input");a[0].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].addEventListener("keyup",this.onBufferKeyUp.bind(this));a[1].setAttribute("min",1);this.root.appendChild(this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT])}this.toolbars[netgis.Modes.SEARCH_PLACE]=
this.createToolbar();this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],this.createToolbarButton('<i class="fas fa-times"></i><span>Suche:</span>',this.onToolbarClose.bind(this)));a=this.createToolbarInputText("Adresse...","",null);a.style.position="relative";this.searchInput=a.getElementsByTagName("input")[0];this.searchInput.addEventListener("keyup",this.onSearchKeyUp.bind(this));this.searchInput.addEventListener("focus",this.onSearchFocus.bind(this));this.searchInput.addEventListener("blur",
this.onSearchBlur.bind(this));this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],a);this.searchList=document.createElement("ul");this.searchList.className="netgis-dropdown-content netgis-search-list netgis-dialog netgis-shadow netgis-hide";a.appendChild(this.searchList);this.append(this.toolbars[netgis.Modes.SEARCH_PLACE],this.createToolbarButton('<i class="fas fa-undo"></i>',this.onSearchClear.bind(this)));this.root.appendChild(this.toolbars[netgis.Modes.SEARCH_PLACE]);this.client.root.appendChild(this.root);
this.client.on(netgis.Events.SET_MODE,this.onSetMode.bind(this));this.client.on(netgis.Events.SEARCH_PLACE_RESPONSE,this.onSearchPlaceResponse.bind(this))};netgis.Toolbar.prototype.createToolbar=function(){var a=document.createElement("div");a.className="netgis-toolbar netgis-dialog netgis-shadow netgis-hide";var b=document.createElement("div");a.appendChild(b);return a};netgis.Toolbar.prototype.append=function(a,b){a.getElementsByTagName("div")[0].appendChild(b)};
netgis.Toolbar.prototype.createToolbarButton=function(a,b){var c=document.createElement("button");c.setAttribute("type","button");c.className="netgis-hover-light";c.innerHTML=a;c.addEventListener("click",b);return c};
netgis.Toolbar.prototype.createToolbarCheckbox=function(a,b){var c=document.createElement("label");c.className="netgis-hover-light";var d=document.createElement("input");d.setAttribute("type","checkbox");d.addEventListener("change",b);c.appendChild(d);a=document.createTextNode(a);c.appendChild(a);return c};
netgis.Toolbar.prototype.createToolbarInput=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";a=document.createTextNode(a);d.appendChild(a);a=document.createElement("input");a.setAttribute("type","number");a.setAttribute("min",0);a.value=b;a.addEventListener("change",c);a.addEventListener("keyup",c);d.appendChild(a);return d};
netgis.Toolbar.prototype.createToolbarInputText=function(a,b,c){var d=document.createElement("label");d.className="netgis-hover-light";var e=document.createElement("input");e.setAttribute("type","text");e.setAttribute("placeholder",a);e.value=b;c&&e.addEventListener("change",c);d.appendChild(e);return d};
netgis.Toolbar.prototype.onSetMode=function(a){var b=!this.toolbars[netgis.Modes.SEARCH_PLACE].classList.contains("netgis-hide");netgis.util.foreach(this.toolbars,function(b,d){b===a?d.classList.remove("netgis-hide"):d.classList.add("netgis-hide")});switch(a){case netgis.Modes.SEARCH_PLACE:b?this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW):this.searchInput.focus();break;case netgis.Modes.BUFFER_FEATURE_EDIT:this.updateBuffer();break;case netgis.Modes.DRAW_POINTS:case netgis.Modes.DRAW_LINES:this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[1].checked&&
this.client.invoke(netgis.Events.DRAW_BUFFER_ON,null)}};netgis.Toolbar.prototype.onToolbarClose=function(a){this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbar.prototype.searchRequest=function(a){a=a.trim();a!==this.searchValue&&(this.searchValue=a,0<a.length&&this.client.invoke(netgis.Events.SEARCH_PLACE_REQUEST,{query:a}))};netgis.Toolbar.prototype.searchClear=function(){this.searchInput.value="";this.searchList.innerHTML=""};
netgis.Toolbar.prototype.searchSelectFirst=function(){var a=this.searchList.getElementsByTagName("button");if(0<a.length)this.onSearchItemClick({target:a[0]})};netgis.Toolbar.prototype.onSearchKeyUp=function(a){var b=a.target;switch(a.keyCode){case 13:this.searchSelectFirst();this.searchList.classList.add("netgis-hide");break;case 27:this.searchClear();break;default:this.searchRequest(b.value)}};netgis.Toolbar.prototype.onSearchChange=function(a){this.searchRequest(a.target.value)};
netgis.Toolbar.prototype.onSearchClear=function(a){this.searchClear();this.searchInput.focus()};netgis.Toolbar.prototype.onSearchFocus=function(a){this.searchList.classList.remove("netgis-hide")};netgis.Toolbar.prototype.onSearchBlur=function(a){this.searchList.classList.add("netgis-hide")};
netgis.Toolbar.prototype.onSearchPlaceResponse=function(a){this.searchList.innerHTML="";a=a.geonames;for(var b=0;b<a.length;b++){var c=a[b],d=document.createElement("li");d.className="netgis-hover-light";var e=document.createElement("button");e.setAttribute("type","button");e.innerHTML=c.title;e.dataset.title=c.title;e.dataset.minx=c.minx;e.dataset.miny=c.miny;e.dataset.maxx=c.maxx;e.dataset.maxy=c.maxy;e.addEventListener("mousedown",this.onSearchItemClick.bind(this));d.appendChild(e);this.searchList.appendChild(d)}};
netgis.Toolbar.prototype.onSearchItemClick=function(a){var b=a.target;a=b.dataset.title;var c=Number.parseFloat(b.dataset.minx),d=Number.parseFloat(b.dataset.miny),e=Number.parseFloat(b.dataset.maxx);b=Number.parseFloat(b.dataset.maxy);this.client.invoke(netgis.Events.MAP_SET_EXTENT,{minx:c,miny:d,maxx:e,maxy:b});this.searchValue=a};
netgis.Toolbar.prototype.updateBuffer=function(){var a=this.toolbars[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input"),b=Number.parseFloat(a[0].value);a=Number.parseInt(a[1].value);this.client.invoke(netgis.Events.BUFFER_CHANGE,{radius:b,segments:a})};netgis.Toolbar.prototype.onBufferChange=function(a){this.updateBuffer()};netgis.Toolbar.prototype.onBufferKeyUp=function(a){this.updateBuffer()};
netgis.Toolbar.prototype.onBufferAccept=function(a){this.client.invoke(netgis.Events.BUFFER_ACCEPT,null);this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbar.prototype.onBufferCancel=function(a){this.client.invoke(netgis.Events.BUFFER_CANCEL,null);this.client.invoke(netgis.Events.SET_MODE,netgis.Modes.VIEW)};
netgis.Toolbar.prototype.onSnapChange=function(a){a=a.target.checked;this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[0].checked=a;this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[0].checked=a;this.toolbars[netgis.Modes.DRAW_POLYGONS].getElementsByTagName("input")[0].checked=a;this.client.invoke(a?netgis.Events.SNAP_ON:netgis.Events.SNAP_OFF,null)};
netgis.Toolbar.prototype.onTracingChange=function(a){a=a.target.checked;var b=this.toolbars[netgis.Modes.DRAW_POLYGONS].getElementsByTagName("input")[0],c=b.checked;a&&!c&&(b.checked=a,this.client.invoke(netgis.Events.SNAP_ON,null));this.client.invoke(a?netgis.Events.TRACING_ON:netgis.Events.TRACING_OFF,null)};
netgis.Toolbar.prototype.onDrawBufferChange=function(a){a=a.target.checked;this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[1].checked=a;this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[1].checked=a;this.client.invoke(a?netgis.Events.DRAW_BUFFER_ON:netgis.Events.DRAW_BUFFER_OFF,null);this.showDrawBufferOptions(a);if(a){a=!0;this.toolbars[netgis.Modes.DRAW_LINES].classList.contains("netgis-hide")||(a=!1);var b=this.toolbars[a?netgis.Modes.DRAW_POINTS:netgis.Modes.DRAW_LINES].getElementsByTagName("input");
a=Number.parseInt(b[2].value);b=Number.parseInt(b[3].value);this.client.invoke(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,a);this.client.invoke(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,b)}};
netgis.Toolbar.prototype.onDrawBufferRadiusChange=function(a){a=a.target;var b=Number.parseFloat(a.value);this.client.invoke(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE,b);var c=this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[2];a!==c&&(c.value=b);c=this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[2];a!==c&&(c.value=b)};
netgis.Toolbar.prototype.onDrawBufferSegmentsChange=function(a){a=a.target;var b=Number.parseInt(a.value);this.client.invoke(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE,b);var c=this.toolbars[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[3];a!==c&&(c.value=b);c=this.toolbars[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[3];a!==c&&(c.value=b)};
netgis.Toolbar.prototype.showDrawBufferOptions=function(a){var b=this.toolbars[netgis.Modes.DRAW_POINTS].children[0].children,c=this.toolbars[netgis.Modes.DRAW_LINES].children[0].children;a?(b[3].classList.remove("netgis-hide"),b[4].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide"),c[4].classList.remove("netgis-hide")):(b[3].classList.add("netgis-hide"),b[4].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"),c[4].classList.add("netgis-hide"))};netgis=netgis||{};netgis.Toolbox=function(a){this.initElements(a);this.initEvents()};
netgis.Toolbox.prototype.initElements=function(a){this.container=document.createElement("section");this.container.className="netgis-toolbox";var b=document.createElement("section");this.container.appendChild(b);this.top=b;this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-hand-paper'></i><span>Betrachten</span>",netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.VIEW));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-map-marker-alt'></i><span>Punkte</span>",
netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.DRAW_POINTS));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-minus'></i><span>Linien</span>",netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.DRAW_LINES));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-vector-square'></i><span>Polygone</span>",netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.DRAW_POLYGONS));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-arrows-alt'></i><span>Verschieben</span>",
netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.MODIFY_FEATURES));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-eraser'></i><span>L\u00f6schen</span>",netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.DELETE_FEATURES));this.addButton(this.top,"<i class='netgis-icon netgis-text-a far fa-dot-circle'></i><span>Puffern</span>",netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.BUFFER_FEATURE_BEGIN));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-cut'></i><span>Ausschneiden</span>",
netgis.util.handler(netgis.Events.SET_MODE,netgis.Modes.CUT_FEATURE_BEGIN));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>Importieren</span>",netgis.util.handler(netgis.Events.IMPORT_SHOW));this.addButton(this.top,"<i class='netgis-icon netgis-text-a fas fa-file-download'></i><span>Exportieren</span>",netgis.util.handler(netgis.Events.EXPORT_SHOW));b=document.createElement("section");b.className="netgis-hide";this.container.appendChild(b);this.bottom=b;
var c=document.createElement("button");c.className="netgis-button netgis-clip-text netgis-color-c";c.innerHTML="<span>Einstellungen</span><i class='netgis-icon fas fa-times'></i>";c.setAttribute("type","button");c.addEventListener("click",this.onBottomHeaderClick.bind(this));b.appendChild(c);this.bottomTitle=c.getElementsByTagName("span")[0];this.bottomPanels={};b=a.tools.buffer.defaultRadius;a=a.tools.buffer.defaultSegments;c=document.createElement("div");this.addCheckbox(c,"Einrasten",netgis.util.handler(netgis.Events.SNAP_TOGGLE));
this.addCheckbox(c,"Puffern",netgis.util.handler(netgis.Events.BUFFER_TOGGLE));this.addInputNumber(c,"Radius (Meter):",b,netgis.util.handler(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE));this.addInputNumber(c,"Segmente:",a,netgis.util.handler(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE));this.bottomPanels[netgis.Modes.DRAW_POINTS]=c;c=document.createElement("div");this.addCheckbox(c,"Einrasten",netgis.util.handler(netgis.Events.SNAP_TOGGLE));this.addCheckbox(c,"Puffern",netgis.util.handler(netgis.Events.BUFFER_TOGGLE));
this.addInputNumber(c,"Radius (Meter):",b,netgis.util.handler(netgis.Events.DRAW_BUFFER_RADIUS_CHANGE));this.addInputNumber(c,"Segmente:",a,netgis.util.handler(netgis.Events.DRAW_BUFFER_SEGMENTS_CHANGE));this.bottomPanels[netgis.Modes.DRAW_LINES]=c;c=document.createElement("div");this.addCheckbox(c,"Einrasten",netgis.util.handler(netgis.Events.SNAP_TOGGLE));this.addCheckbox(c,"Tracing",netgis.util.handler(netgis.Events.TRACING_TOGGLE));this.bottomPanels[netgis.Modes.DRAW_POLYGONS]=c;c=document.createElement("div");
this.addInputNumber(c,"Radius (Meter):",b,this.onBufferFeatureChange.bind(this));this.addInputNumber(c,"Segmente:",a,this.onBufferFeatureChange.bind(this));this.addButton(c,"<i class='netgis-icon netgis-text-a fas fa-arrow-circle-right'></i><span>Akzeptieren</span>",this.onBufferFeatureAccept.bind(this));this.bottomPanels[netgis.Modes.BUFFER_FEATURE_EDIT]=c;b=document.createElement("div");this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>Shapefile</span>",netgis.util.handler(netgis.Events.IMPORT_SHAPEFILE_SHOW));
this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>GeoJSON</span>",netgis.util.handler(netgis.Events.IMPORT_GEOJSON_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>GML</span>",netgis.util.handler(netgis.Events.IMPORT_GML_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>Spatialite</span>",netgis.util.handler(netgis.Events.IMPORT_SPATIALITE_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-upload'></i><span>Geopackage</span>",
netgis.util.handler(netgis.Events.IMPORT_GEOPACKAGE_SHOW));this.bottomPanels[netgis.Modes.IMPORT]=b;b=document.createElement("div");this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-download'></i><span>PDF</span>",netgis.util.handler(netgis.Events.EXPORT_PDF_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-download'></i><span>JPEG</span>",netgis.util.handler(netgis.Events.EXPORT_JPEG_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-download'></i><span>PNG</span>",
netgis.util.handler(netgis.Events.EXPORT_PNG_SHOW));this.addButton(b,"<i class='netgis-icon netgis-text-a fas fa-file-download'></i><span>GIF</span>",netgis.util.handler(netgis.Events.EXPORT_GIF_SHOW));this.bottomPanels[netgis.Modes.EXPORT]=b;this.setBuffer(!1)};netgis.Toolbox.prototype.initEvents=function(){this.resizeObserver=(new ResizeObserver(this.onTopResize.bind(this))).observe(this.top)};netgis.Toolbox.prototype.attach=function(a){a.appendChild(this.container)};
netgis.Toolbox.prototype.addButton=function(a,b,c){var d=document.createElement("button");d.className="netgis-button netgis-clip-text netgis-color-e netgis-hover-a";d.innerHTML=b;d.setAttribute("type","button");c&&(d.onclick=c);a&&a.appendChild(d);return d};
netgis.Toolbox.prototype.addCheckbox=function(a,b,c){var d=document.createElement("label");d.className="netgis-noselect netgis-hover-a";var e=document.createElement("input");e.setAttribute("type","checkbox");d.appendChild(e);var f=document.createElement("span");f.innerHTML=b;d.appendChild(f);c&&(e.onchange=c);a&&a.appendChild(d);return e};
netgis.Toolbox.prototype.addInputNumber=function(a,b,c,d){var e=document.createElement("label");e.className="netgis-noselect netgis-hover-a";var f=document.createElement("span");f.innerHTML=b;e.appendChild(f);b=document.createElement("input");b.setAttribute("type","number");b.setAttribute("min",0);b.value=c;e.appendChild(b);d&&(b.onchange=d,b.onkeyup=d);a&&a.appendChild(e);return b};
netgis.Toolbox.prototype.setMode=function(a){for(var b=this.top.getElementsByTagName("button"),c=0;c<b.length;c++)b[c].classList.remove("netgis-bold");for(var d in this.bottomPanels)c=this.bottomPanels[d],c.parentNode===this.bottom&&this.bottom.removeChild(c);switch(a){case netgis.Modes.VIEW:b[0].classList.add("netgis-bold");this.bottomTitle.innerHTML="";break;case netgis.Modes.DRAW_POINTS:b[1].classList.add("netgis-bold");this.bottomTitle.innerHTML="Punkte";break;case netgis.Modes.DRAW_LINES:b[2].classList.add("netgis-bold");
this.bottomTitle.innerHTML="Linien";break;case netgis.Modes.DRAW_POLYGONS:b[3].classList.add("netgis-bold");this.bottomTitle.innerHTML="Polygone";break;case netgis.Modes.MODIFY_FEATURES:b[4].classList.add("netgis-bold");this.bottomTitle.innerHTML="Verschieben";break;case netgis.Modes.DELETE_FEATURES:b[5].classList.add("netgis-bold");this.bottomTitle.innerHTML="L\u00f6schen";break;case netgis.Modes.BUFFER_FEATURE_BEGIN:case netgis.Modes.BUFFER_FEATURE_EDIT:b[6].classList.add("netgis-bold");this.bottomTitle.innerHTML=
"Puffern";break;case netgis.Modes.CUT_FEATURE_BEGIN:case netgis.Modes.CUT_FEATURE_DRAW:b[7].classList.add("netgis-bold");this.bottomTitle.innerHTML="Ausschneiden";break;case netgis.Modes.IMPORT:b[8].classList.add("netgis-bold");this.bottomTitle.innerHTML="Importieren";break;case netgis.Modes.EXPORT:b[9].classList.add("netgis-bold"),this.bottomTitle.innerHTML="Exportieren"}(c=this.bottomPanels[a])?(this.bottom.appendChild(c),this.showBottom()):this.hideBottom()};
netgis.Toolbox.prototype.setSnap=function(a){this.bottomPanels[netgis.Modes.DRAW_POINTS].getElementsByTagName("input")[0].checked=a;this.bottomPanels[netgis.Modes.DRAW_LINES].getElementsByTagName("input")[0].checked=a;this.bottomPanels[netgis.Modes.DRAW_POLYGONS].getElementsByTagName("input")[0].checked=a};
netgis.Toolbox.prototype.setBuffer=function(a){var b=this.bottomPanels[netgis.Modes.DRAW_POINTS].getElementsByTagName("label"),c=this.bottomPanels[netgis.Modes.DRAW_LINES].getElementsByTagName("label");b[1].getElementsByTagName("input")[0].checked=a;(c[1].getElementsByTagName("input")[0].checked=a)?(b[2].classList.remove("netgis-hide"),b[3].classList.remove("netgis-hide"),c[2].classList.remove("netgis-hide"),c[3].classList.remove("netgis-hide")):(b[2].classList.add("netgis-hide"),b[3].classList.add("netgis-hide"),
c[2].classList.add("netgis-hide"),c[3].classList.add("netgis-hide"))};netgis.Toolbox.prototype.setBufferRadius=function(a){var b=this.bottomPanels[netgis.Modes.DRAW_POINTS].getElementsByTagName("input"),c=this.bottomPanels[netgis.Modes.DRAW_LINES].getElementsByTagName("input");b[2].value=a;c[2].value=a};
netgis.Toolbox.prototype.setBufferSegments=function(a){var b=this.bottomPanels[netgis.Modes.DRAW_POINTS].getElementsByTagName("input"),c=this.bottomPanels[netgis.Modes.DRAW_LINES].getElementsByTagName("input");b[3].value=a;c[3].value=a};netgis.Toolbox.prototype.showBottom=function(){this.top.classList.add("netgis-resize-bottom");this.top.style.height="50%";this.top.style.bottom="auto";this.bottom.classList.remove("netgis-hide")};
netgis.Toolbox.prototype.hideBottom=function(){this.top.classList.remove("netgis-resize-bottom");this.top.style.height="auto";this.top.style.bottom="0mm";this.bottom.classList.add("netgis-hide")};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.container,netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis.Toolbox.prototype.onBufferFeatureChange=function(a){var b=this.bottomPanels[netgis.Modes.BUFFER_FEATURE_EDIT].getElementsByTagName("input");a=Number.parseFloat(b[0].value);b=Number.parseInt(b[1].value);netgis.util.invoke(this.container,netgis.Events.BUFFER_CHANGE,{radius:a,segments:b})};
netgis.Toolbox.prototype.onBufferFeatureAccept=function(a){netgis.util.invoke(this.container,netgis.Events.BUFFER_ACCEPT,null);netgis.util.invoke(this.container,netgis.Events.SET_MODE,netgis.Modes.VIEW)};netgis=netgis||{};netgis.Tree=function(){this.initElements()};netgis.Tree.Events=Object.freeze({ITEM_CHANGE:"item-change"});netgis.Tree.prototype.initElements=function(){var a=document.createElement("ul");a.className="netgis-tree";this.container=a};netgis.Tree.prototype.attach=function(a){a.appendChild(this.container)};
netgis.Tree.prototype.addFolder=function(a,b,c,d){var e=document.createElement("li");e.className="netgis-folder";e.setAttribute("data-id",b);b=document.createElement("details");e.appendChild(b);var f=document.createElement("summary");f.className="netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-a";f.innerHTML="<i class='netgis-icon netgis-hide-open fas fa-folder'></i><i class='netgis-icon netgis-show-open fas fa-folder-open'></i><span>"+c+"</span>";b.appendChild(f);c=document.createElement("label");
f.appendChild(c);f=document.createElement("input");f.setAttribute("type","checkbox");f.onchange=this.onFolderChange.bind(this);c.appendChild(f);c=document.createElement("ul");b.appendChild(c);a=a?a.getElementsByTagName("ul")[0]:this.container;d?a.insertBefore(e,a.firstChild):a.appendChild(e);return e};
netgis.Tree.prototype.addCheckbox=function(a,b,c){var d=document.createElement("li");d.className="netgis-item";var e=document.createElement("label");e.className="netgis-button netgis-noselect netgis-clip-text netgis-color-e netgis-hover-a";e.innerHTML="<span>"+c+"</span>";d.appendChild(e);c=document.createElement("input");c.setAttribute("type","checkbox");c.setAttribute("data-id",b);c.onchange=this.onItemChange.bind(this);e.insertBefore(c,e.firstChild);a?a.getElementsByTagName("ul")[0].appendChild(d):
this.container.appendChild(d);return d};netgis.Tree.prototype.addButton=function(a,b,c){var d=document.createElement("li"),e=document.createElement("button");e.innerHTML=b;e.className="netgis-button netgis-color-e netgis-text-a netgis-hover-a netgis-clip-text";e.setAttribute("type","button");d.appendChild(e);c&&(e.onclick=c);a?a.getElementsByTagName("ul")[0].appendChild(d):this.container.appendChild(d);return d};
netgis.Tree.prototype.setItemChecked=function(a,b){var c=this.container.getElementsByClassName("netgis-item");a=a.toString();for(var d=0;d<c.length;d++){var e=c[d].getElementsByTagName("input")[0];e.getAttribute("data-id")===a&&e.checked!==b&&e.click()}};netgis.Tree.prototype.setFolderParent=function(a,b){var c=a.parentNode;c&&c.removeChild(a);null!==b?b.getElementsByTagName("ul")[0].appendChild(a):this.container.appendChild(a)};
netgis.Tree.prototype.updateFolderCheck=function(a){a||(a=this.container);for(var b=a.getElementsByClassName("netgis-item"),c=0,d=0;d<b.length;d++){var e=b[d].getElementsByTagName("input")[0];e.checked&&c++}e=a.getElementsByTagName("input")[0];d=0;0<c&&(d=1);c===b.length&&(d=2);switch(d){case 0:e.checked=!1;e.classList.remove("netgis-partial");break;case 1:e.checked=!0;e.classList.add("netgis-partial");break;case 2:e.checked=!0,e.classList.remove("netgis-partial")}(a=a.parentElement)&&a!==this.container&&
(a=a.parentElement.parentElement)&&-1!==a.className.search("netgis-folder")&&this.updateFolderCheck(a)};netgis.Tree.prototype.onFolderChange=function(a){var b=a.currentTarget;a=b.checked;b=b.parentElement.parentElement.parentElement.parentElement;for(var c=b.getElementsByTagName("input"),d=1;d<c.length;d++){var e=c[d];e.checked!==a&&e.click()}this.updateFolderCheck(b);a=b.parentElement.parentElement.parentElement;-1!==a.className.search("netgis-folder")&&this.updateFolderCheck(a)};
netgis.Tree.prototype.onItemChange=function(a){a=a.currentTarget;var b=a.checked,c=a.getAttribute("data-id"),d=Number.parseInt(c);Number.isNaN(d)||(c=d);d=a.parentElement.parentElement.parentElement.parentElement.parentElement;netgis.util.invoke(a,netgis.Tree.Events.ITEM_CHANGE,{id:c,checked:b});-1!==d.className.search("netgis-folder")&&this.updateFolderCheck(d)};netgis=netgis||{};
netgis.util=function(){var a=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(c,a[c])},b=function(){return navigator.language||"de-DE"};return{isDefined:function(a){return"undefined"!==typeof a},isString:function(a){return"string"===typeof a||a instanceof String},replace:function(a,b,e){return a.replace(new RegExp(b,"g"),e)},foreach:a,template:function(b,d){a(d,function(a,c){b=b.replace(new RegExp("{"+a+"}","g"),c)});return b},newlines:function(a){return a.replace(/\n/g,"<br />")},create:function(a){var b=
document.createElement("tbody");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){var c=new XMLHttpRequest;c.onload=function(){b(this.responseText)};c.open("GET",a,!0);c.send()},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]},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)}}}}();