'),h=_.map(c,function(c){var d=_.findIndex(a,function(a){return a===c});return i(c,d,b,f,a)},this);return g.append(h),e.append('
'+d+"
"),e.append(g),e}).value();c.html(o),c.scrollTop(0)}var l=KR.Util.getDatasetTemplate("popup"),m=new a;return c=$(c),b=$(b),d=$(d),{showFeature:j,showFeatures:k,setMap:function(a){m.setMap(a)}}}}();var KR=this.KR||{};KR.DatasetLoader=function(a,b,c,d,e,f){"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f,unclusterThreshold:a.unclusterThreshold}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()
g&&u("down"),c.on("dataloadend",t),KR.Util.checkThresholdPassed(d,g,u),c.on("click",p),d.on("layerDeselect",n)};return{initKulturminnePoly:v}}}(KR.Config);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getDatasetList=function(b,c,d){var e=a.getKulturminneFunctions(b);c&&3===c.length&&(c="0"+c);var f={difo:{name:"Digitalt fortalt",dataset:{dataset:"difo",api:"norvegiana"},cluster:!0,template:KR.Util.getDatasetTemplate("digitalt_fortalt"),noListThreshold:1/0,description:"Kulturrådets tjeneste for personlige fortellinger fra kulturinstitusjoner og privatpersoner.",allowTopic:!0,feedbackForm:!0,isStatic:!1},verneomr:{id:"verneomraader",dataset:{api:"cartodb",table:"naturvernomrader_utm33_2",columns:["iid","omradenavn","vernef_id","verneform"]},provider:"Naturbase",name:"Verneområder",template:KR.Util.getDatasetTemplate("verneomraader"),getFeatureData:function(a,c){b.getItem({api:"norvegiana",id:"kulturnett_Naturbase_"+a.properties.iid},c)},toPoint:{showAlways:!0,stopPolyClick:!0,minSize:20},minZoom:10,cluster:!1,description:"Nasjonalparker og andre naturvernområder - ca. 2700 i hele landet."},artobs:{name:"Artsobservasjoner",hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"Artsdatabanken"},cluster:!1,description:"Artsobservasjoner fra Artsdatabanken",template:KR.Util.getDatasetTemplate("popup")},folketelling:{name:"Folketelling 1910",provider:"Folketelling 1910",dataset:{api:"folketelling",dataset:"property"},isStatic:!1,minZoom:14,template:KR.Util.getDatasetTemplate("folketelling"),getFeatureData:function(a,c){
-b.getData({api:"folketelling",type:"propertyData",propertyId:a.properties.efid},function(b){a.properties=b.properties,a.properties.provider="Folketelling 1910",c(a)})},mappings:{title:"gaardsnavn_gateadr"},noListThreshold:0,description:"Personer og eiendommer fra folketellingen 1910"},ark_hist:{grouped:!0,name:"Arkeologi og historie",minZoom:14,datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly}],description:"Data fra Universitetsmuseene, Digitalt museum og Riksantikvaren"},jernbane:{id:"jernbane",dataset:{api:"jernbanemuseet"},provider:"Jernbanemuseet",name:"Jernbanemuseet",hideFromGenerator:!0,template:KR.Util.getDatasetTemplate("jernbanemuseet"),getFeatureData:function(a,c){b.getItem({api:"jernbanemuseet",id:a.properties.id},c)},isStatic:!0,bbox:!1,description:"Jernbanemuseet"},arkeologi:{grouped:!0,name:"Arkeologi",minZoom:14,style:{fillcolor:"#436978",circle:!1,thumbnail:!0},datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER regex(?loccatlabel, "^Arkeologisk", "i") .',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly}],description:"Arkeologidata fra Universitetsmuseene og Riksantikvaren"},historie:{grouped:!0,name:"Historie",minZoom:14,style:{fillcolor:"#D252B9",circle:!1,thumbnail:!0},datasets:[{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER (!regex(?loccatlabel, "^Arkeologisk", "i"))',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"-dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Industrimuseum"},isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Foto-SF"},isStatic:!1,bbox:!1,template:KR.Util.getDatasetTemplate("foto_sf")},{dataset:{api:"norvegiana",dataset:"Kystreise"},isStatic:!0,bbox:!1}],description:"Historie og kulturminner fra Riksantikvaren og Digitalt museum "},kunst:{grouped:!0,name:"Kunst",style:{fillcolor:"#72B026",circle:!1,thumbnail:!0},datasets:[{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1}],description:"Kunstdata fra Digitalt museum "},wikipedia:{name:"Wikipedia",provider:"Wikipedia",dataset:{api:"wikipedia"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra bokmålswikipedia"},wikipediaNN:{name:"Wikipedia Nynorsk",provider:"Wikipedia Nynorsk",dataset:{api:"wikipediaNN"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra nynorskwikipedia"},lokalwiki:{id:"lokalwiki",name:"Lokalhistoriewiki",hideFromGenerator:!1,provider:"Lokalhistoriewiki",dataset:{api:"lokalhistoriewiki"},style:{thumbnail:!0},minZoom:13,bbox:!0,isStatic:!1,description:"Stedfestede artikler fra lokalhistoriewiki.no"},riksantikvaren:{id:"riksantikvaren",name:"Kulturminnesøk",hideFromGenerator:!1,provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,unclusterThreshold:13,init:e.initKulturminnePoly,description:"Data fra Riksantikvarens kulturminnesøk"},brukerminner:{name:"Kulturminnesøk - brukerregistreringer",hideFromGenerator:!1,provider:"riksantikvaren",dataset:{api:"kulturminnedata",layer:2,getExtraData:!0,extraDataLayer:6,matchId:"KulturminnesokID"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Brukerregistrerte data fra Riksantikvarens kulturminnesøk",template:KR.Util.getDatasetTemplate("brukerminne")},groruddalen:{name:"Byantikvaren Oslo - Groruddalen",hideFromGenerator:!0,provider:"Byantikvaren i Oslo",dataset:{api:"cartodb",table:"byantikvaren_oslo_groruddalen"},bbox:!1,isStatic:!1,style:{thumbnail:!0},template:KR.Util.getDatasetTemplate("byantikvaren_oslo"),description:"Byantikvarens Groruddalsatlas"},norgerundt:{name:"Norge Rundt",hideFromGenerator:!0,provider:"NRK",dataset:{api:"cartodb",table:"nrk_norge_rundt"},bbox:!1,isStatic:!1,style:{thumbnail:!0},description:"Stedfestede innslag fra Norge Rundt"},dimu:{name:"Digitalt Museum",hideFromGenerator:!1,provider:"dimu",dataset:{dataset:"DiMu",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Digitalt Museum",allowTopic:!0,feedbackForm:!0},musit:{name:"Universitetsmuseene",hideFromGenerator:!1,provider:"Universitetsmuseene",dataset:{dataset:"MUSIT",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Universitetsmuseene",allowTopic:!0,feedbackForm:!0},industrimuseum:{name:"Industrimuseum",hideFromGenerator:!1,provider:"Industrimuseum",dataset:{dataset:"Industrimuseum",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Industrimuseum",allowTopic:!0,feedbackForm:!0},kystreise:{name:"Kystreise",hideFromGenerator:!1,provider:"Kystreise",dataset:{dataset:"Kystreise",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Kystreise",allowTopic:!0,feedbackForm:!0},dimufoto:{hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"DiMu",query:"europeana_type_facet:IMAGE"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,style:{thumbnail:!0},noListThreshold:1/0},kulturminnesok_flickr:{name:"Kulturminnesøk",dataset_name_override:"Kulturminnesøk",provider:"Kulturminnesøk Flickr",hideFromGenerator:!0,dataset:{api:"flickr",group_id:"1426230@N24"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!0,style:{thumbnail:!0},description:"Bilder fra Kulturminnesøks Flickr-gruppe"},riksarkivet:{name:"Riksarkivet",dataset_name_override:"Riksarkivet",provider:"riksarkivet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_archives_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Riksarkivets Flickr-konto"},nasjonalbiblioteket:{name:"Nasjonalbiblioteket",dataset_name_override:"Nasjonalbiblioteket",provider:"nasjonalbiblioteket",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_library_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalbibliotekets Flickr-konto"},oslobyarkiv:{name:"Oslo Byarkiv",dataset_name_override:"Oslo Byarkiv",provider:"oslobyarkiv",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"byarkiv"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Oslo byarkiv sin Flickr-konto"},nasjonalmuseet:{name:"Nasjonalmuseet",dataset_name_override:"Nasjonalmuseet",provider:"nasjonalmuseet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nasjonalmuseet"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalmuseet sin Flickr-konto"},nve:{name:"NVE",dataset_name_override:"NVE",provider:"nve",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nve",accuracy:"6"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra NVE Flickr-konto"},vestfoldmuseene:{name:"Vestfoldmuseene",dataset_name_override:"Vestfoldmuseene",provider:"Vestfoldmuseene",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"vestfoldmuseene",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Vestfoldmuseene sin Flickr-konto"},perspektivet:{name:"Perspektivet Museum",dataset_name_override:"Perspektivet Museum",provider:"Perspektivet Museum",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"perspektivetmuseum",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Perspektivet Museum sin Flickr-konto"}};if(!c&&!d){var g={bbox:!0,minZoom:12,isStatic:!1,bboxFunc:KR.Util.sparqlBbox};_.extend(f.riksantikvaren,g),_.extend(f.ark_hist.datasets[2],g),_.extend(f.arkeologi.datasets[1],g),_.extend(f.historie.datasets[0],g)}return f},a.getDatasets=function(b,c,d,e){var f=a.getDatasetList(c,d,e);return _.chain(b).map(function(a){var b;if(a.indexOf(":")>-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};!function(a){"use strict";function b(a){return turf.featurecollection([turf.simplify(a.features[0],.001,!1)])}function c(a,b){return b=b||{},{polyline:{positions:a,width:5,material:new Cesium.PolylineOutlineMaterialProperty({color:Cesium.Color.ORANGE,outlineWidth:2,outlineColor:Cesium.Color.BLACK})}}}function d(a,b,c){var d=a.layer||"topo2";if("norges_grunnkart_graatone"===d&&(d="norges_grunnkart"),"hist"===d)c(b.getWms("http://wms.geonorge.no/skwms1/wms.historiskekart","historiskekart"));else if("nib"===d){var e="http://knreise.no/nib/?type=token";KR.Util.sendRequest(e,null,function(a){c(0!==a.indexOf("**")?b.getWmts("http://crossorigin.me/http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts","NiB",{TILEMATRIXSET:"EPSG:900913",TILEMATRIX:"EPSG:900913:{TileMatrix}",FORMAT:"image/jpeg",GKT:a}):b.getTiles("http://www.webatlas.no/wacloud/servicerepository/combine.aspx?X={x}&Y={y}&Z={z}&layers=TMS_WEBATLAS_STANDARD:1"))})}else c(b.getWmts("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts",d,{TILEMATRIXSET:"EPSG:3857",TILEMATRIX:"EPSG:3857:{TileMatrix}",FORMAT:"image/png"}))}function e(a){function b(){e.find(".glyphicon").removeClass("glyphicon-play").addClass("glyphicon-pause"),a.start()}function c(){e.find(".glyphicon").removeClass("glyphicon-pause").addClass("glyphicon-play"),a.stop()}function d(){a.isRunning()?c():b()}var e=$("#playpause");return{play:b,pause:c,toggle:d}}var f={animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,navigationHelpButton:!0,navigationInstructionsInitiallyVisible:!1,orderIndependentTranslucency:!1};a.setupMap3d=function(a,g,h){function i(){var b=KR.Config.getDatasets(g,a);return _.chain(b).map(function(a){return a.datasets?a.datasets:a}).flatten().filter(function(a){return _.has(a.dataset,"kommune")&&_.isUndefined(a.dataset.kommune)?!1:!0}).value()}function j(a,b){return new KR.CesiumMap(a,_.extend(f,{limitBounds:h.limitBounds,terrainUrl:h.terrainUrl,enableLighting:h.enableLighting}),b)}function k(b,c,d){_.each(b,function(b){var d=KR.Util.getDatasetId(b),e={template:b.template,datasetId:d,"marker-color":KR.Style.colorForFeature({properties:{datasetId:d}},!1)};o.loadDataset2(b.dataset,c,a,e)}),o.addClickhandler(function(a){q.show(a),d&&d()})}function l(a){o=j("cesium-viewer",a),o.viewer.scene.imageryLayers.removeAll(),d(h,o,o.addImageryProvider),k(i(),a),o.stopLoading()}function m(){var f,g,l=!1;KR.Util.getLine(a,h.line,function(a){if(p=KR.CesiumUtils.getBounds(a),o=j("cesium-viewer",p),d(h,o,o.addImageryProvider),k(i(),p,function(){h.player&&(l=f.isRunning(),g.pause(),f.stop())}),o.build3DLine(a,function(a){var b=c(a,{color:Cesium.Color.DEEPSKYBLUE,glow:.25});o.viewer.zoomTo(o.viewer.entities.add(b)),o.stopLoading()}),h.player){var m=b(a);o.build3DLine(m,function(a){f=new KR.PathTracer(o.viewer,a,m),f.setPitchCorr(.1),g=new e(f),$("#playpause").removeClass("hidden"),$("#playpause").click(g.toggle)}),q.addCloseCb(function(){l&&g.play()})}})}function n(){h.bbox?l(h.bbox):h.komm?a.getMunicipalityBounds(h.komm,l):h.line?m():alert("Missing parameters!")}h=h||{},h=_.extend({player:!0,limitBounds:!1},h);var o,p,q=KR.CesiumSidebar($("#cesium-sidebar"),{});n()}}(KR);
\ No newline at end of file
+var KR=this.KR||{};!function(a){"use strict";a.parseError=function(a){if(a.responseJSON){if(a.responseJSON.error)return a.responseJSON.error.join(", ");if(a.responseJSON.status)return a.responseJSON.status}return a.statusText?a.statusText:a.error?a.error.info?a.error.info:a.error.error?a.error.error:a.error:"Unknown error"},a.errorHandler=function(b){var c=$(b);c.find(".close").on("click",function(){c.find(".content").html(""),c.remove()});var d=_.template("<%= dataset %>: <%= error %>
");return function(b){var e=d({dataset:b.dataset,error:a.parseError(b.error)});c.parent()?c.find(".content").append(e):c.find(".content").html(e),$("body").append(c)}}}(KR);var KR=this.KR||{};KR.Config={contentIcons:{IMAGE:"camera-retro",VIDEO:"file-video-o",SOUND:"music",TEXT:"file-text","default":"file-o"},templates:{}},KR.Config.ImageCaheUrl="http://egbtmre.cloudimg.io",KR.Util=KR.Util||{},function(a){"use strict";function b(a,b){var c=a.lastIndexOf(b);return-1!==c&&c+b.length===a.length}function c(a){return 1e3>a?"0"+a:a}a.iconForContentType=function(a){var b=a.properties.contentType;return _.has(KR.Config.contentIcons,b)?KR.Config.contentIcons[b]:KR.Config.contentIcons["default"]},a.getDatasetTemplate=function(a){var b=$("#"+a+"_template").html();return b?_.template(b):void 0},a.templateForDataset=function(a){return _.has(KR.Config.templates,a)?KR.Config.templates[a]:void 0},a.createStyleString=function(a){return _.map(a,function(a,b){return b+": "+a}).join(";")},a.colorForProvider=function(a,b){var c=!0;"hex"!==b&&(c=!1);var d={properties:{datasetId:a}};return KR.Style.colorForFeature(d,c,!0)},a.featureClick=function(a){return function(b,c,d){c.on("click",function(c){d&&d.toPoint&&d.toPoint.stopPolyClick&&!c.parent||(d?a.showFeature(b,d.template,d.getFeatureData):a.showFeature(b))})}},a.getTemplateForFeature=function(a,b){if(b){if(b.datasets){var c=_.find(b.datasets,function(b){return b._knreise_id===a.properties.datasetID});return c.template}return b.template}},a.clusterClick=function(b){return function(c,d){c.on("clusterclick",function(c){var e=_.map(c.layer.getAllChildMarkers(),function(b){var c=b.feature;return d&&!c.template&&(c.template=a.getTemplateForFeature(c,d)),c}),f=_.extend({},{template:null,getFeatureData:null,noListThreshold:null},d);b.showFeatures(e,f.template,f.getFeatureData,f.noListThreshold)})}},a.hexToRgba=function(a,b){b=b||1;var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(!c)return 0;var d={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)};return"rgba("+d.r+","+d.g+","+d.b+","+b+")"},a.filterByBbox=function(a,b){var c=turf.featurecollection([turf.bboxPolygon(KR.Util.splitBbox(b))]);return turf.within(a,c)},a.getDatasetId=function(a){return"norvegiana"===a.dataset.api?a.dataset.dataset:"wikipedia"===a.dataset.api?"wikipedia":a.id?a.id:KR.Util.stamp(a)},"undefined"!=typeof L&&(L.latLngBounds.fromBBoxArray=function(a){return new L.LatLngBounds(new L.LatLng(a[1],a[0]),new L.LatLng(a[3],a[2]))},L.latLngBounds.fromBBoxString=function(a){return L.latLngBounds.fromBBoxArray(KR.Util.splitBbox(a))},L.rectangle.fromBounds=function(a){return L.rectangle([a.getSouthWest(),a.getNorthEast()])}),a.parseQueryString=function(a){var b=decodeURIComponent(a);if(""!==b)return _.reduce(b.replace("?","").split("&"),function(a,b){b=b.split("=");var c=b[1];return"true"===c?c=!0:"false"===c&&(c=!1),a[b[0]]=c,a},{})};var d=_.template("<%= totalt %> (<%= menn %> menn, <%= kvinner %> kvinner)");a.formatPersons=function(a){var b=a.split("-");return b.length<2?a:d({totalt:b[0],menn:b[1],kvinner:b[2]})},a.getBaseLayer=function(a,b){var c={nib:KR.getNibLayer,hist:function(a){a(L.tileLayer.wms("http://wms.geonorge.no/skwms1/wms.historiskekart",{layers:"historiskekart",format:"image/png",attribution:"Kartverket"}))}};if(_.has(c,a))c[a](b);else{var d=navigator.userAgent.indexOf("Safari")>-1,e=!d;b(L.tileLayer.kartverket(a,{useCache:e}))}},a.getLine=function(a,c,d){if(_.isFunction(c))return void c(function(a){d(a)});var e;if(0===c.indexOf("utno/")){var f=c.replace("utno/","");e={api:"utno",id:f,type:"gpx"}}else 0===c.indexOf("http")&&(b(c,"kml")?e={api:"kml",url:c}:b(c,"gpx")||-1!==c.indexOf("http://ut.no/tur/")?e={api:"gpx",url:c}:b(c,"geojson")&&(e={api:"geojson",url:c}));e?a.getData(e,function(a){d(a)}):alert("Kunne ikke laste linjegeometri")},a.messageDisplayer=function(a){return function(b,c){var d=$(a);d.find(".close").on("click",function(){d.find(".content").html(""),d.remove()}),d.addClass("alert-"+b),d.find(".content").html(c),$("body").append(d)}},a.mostlyCoveringMunicipality=function(a,b,c){var d="ST_MakeEnvelope("+b+", 4326)",e="SELECT komm FROM kommuner WHERE ST_Intersects(the_geom, "+d+")ORDER BY st_area(st_intersection(the_geom, "+d+")) DESC LIMIT 1",f={api:"cartodb",query:e,mapper:function(a){return a.rows[0].komm}};a.getData(f,c)},a.sparqlBbox=function(a,b,d,e,f){KR.Util.mostlyCoveringMunicipality(a,d,function(d){b.kommune=c(d),a.getData(b,e,f)})},a.distanceAndSort=function(a,b){var c=_.map(a.features,function(a){return a.properties.distance=turf.distance(b,a),a});return turf.featurecollection(c.sort(function(a,b){return a.properties.distanceb.properties.distance?1:0}))},a.round=function(a,b){_.isUndefined(b)&&(b=2);var c=Math.pow(10,b);return Math.round(a*c)/c};var e=_.template("#<%= zoom %>/<%= lat %>/<%= lon %>");a.getPositionHash=function(b,c,d){return e({zoom:d,lat:a.round(b,4),lon:a.round(c,4)})},a.WORLD={type:"Feature",geometry:{type:"Polygon",coordinates:[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]]}},a.createMap=function(b,c){c=c||{};var d=L.map(b,{minZoom:c.minZoom||3,maxZoom:c.maxZoom||18,maxBounds:L.geoJson(a.WORLD).getBounds()}),e=c.layer||"norges_grunnkart_graatone";return _.isString(e)?KR.Util.getBaseLayer(e,function(a){a.addTo(d)}):e.addTo(d),d},a.setupSidebar=function(a,b){b=b||{};var c=KR.Util.getDatasetTemplate("popup"),d=_.template($("#list_item_template").html()),e=_.template($("#marker_template").html()),f=_.template($("#thumbnail_template").html()),g=_.template($("#footer_template").html()),h=_.extend({},{position:"left",template:c,listElementTemplate:d,markerTemplate:e,thumbnailTemplate:f,footerTemplate:g},b),i=L.Knreise.Control.sidebar("sidebar",h);return a.addControl(i),i},a.distanceAndBearing=function(a,b){return{distance:1e3*turf.distance(a,b,"kilometers"),bearing:turf.bearing(a,b)}};var f=_.template("<%= service %>/s/crop/<%= width %>x<%= height %>/<%= image %>");a.getImageCache=function(a,b,c){return KR.Config.ImageCaheUrl?f({service:KR.Config.ImageCaheUrl,width:b,height:c,image:a}):a},a.isInIframe=function(){try{return window.self!==window.top}catch(a){return!0}},a.checkThresholdPassed=function(a,b,c){var d;a.on("zoomstart",function(b){d=a.getZoom()}),a.on("zoomend",function(e){var f=a.getZoom();d>b&&b>=f&&c("up"),b>=d&&f>b&&c("down")})}}(KR.Util);var KR=this.KR||{};KR.Style={},function(a){"use strict";function b(a){var b=a.properties.vernef_id;return _.find(p,function(a){return-1!==a.ids.indexOf(b)})}function c(a){return u[a]||"blue"}function d(a,b,c,d){return _.isFunction(a[b])?d?a[b]():a[b](c):a[b]}function e(a,b,c){return c?d(a,"fillcolor",b,!0):d(a,"fillcolor",b)}function f(a,b){return a.bordercolor?d(a,"bordercolor",b):e(a,b)}function g(b){return a.groups[b]}function h(b){var c;return b.properties&&b.properties.groupId?g(b.properties.groupId):(b.properties&&b.properties.datasetId&&(c=a.getDatasetStyle(b.properties.datasetId)),c?c:_.extend({},s))}function i(a,b,c){return c=c||9,{radius:c,weight:1,opacity:1,color:a,fillColor:b,fillOpacity:.4}}function j(a,b,c){return L.circleMarker(a,i(b,c))}function k(a){return L.Knreise.icon({markerColor:a})}function l(a,b,c){var d="";return a.properties&&a.properties.title&&(d=a.properties.title),L.marker(b,{icon:c,title:d})}function m(a,b,c){if(a.properties&&a.properties.thumbnail){var d={"border-color":b,"background-image":"url("+a.properties.thumbnail+")"};c&&(d["border-width"]="3px");var e=KR.Util.getImageCache(a.properties.thumbnail,50,50),f='';return new L.DivIcon({className:"leaflet-marker-circle",html:f,iconSize:[50,50],iconAnchor:[25,25]})}}function n(a,b,c){var d=_.filter(a,function(a){return a.feature.properties.thumbnail});if(d.length){var e;_.isArray(b)&&(e=_.rest(b),b=b[0]);var f=KR.Util.getImageCache(d[0].feature.properties.thumbnail,50,50),g={"border-color":b,"background-image":"url("+f+");"};e&&(g["box-shadow"]=_.map(e,function(a,b){var c=2*(b+1);return"0 0 0 "+c+"px "+a}).join(",")+";"),c&&(g["border-width"]="3px");var h=''+a.length+"";return new L.DivIcon({className:"leaflet-marker-photo",html:h,iconSize:[60,60],iconAnchor:[30,30]})}}function o(a,b){var c=KR.Util.hexToRgba(b,.4);return new L.DivIcon({className:"leaflet-marker-circle",html:''+a.length+"",iconSize:[20,20],iconAnchor:[10,10]})}var p={landskapsvern:{ids:["LVO","LVOD","LVOP","LVOPD","BV","MAV","P","GVS","MIV","NM","BVV","PO","DO","D"],style:{fillColor:"#d8cb7a",color:"#9c8f1b"}},nasjonalpark:{ids:["NP","NPS"],style:{fillColor:"#7f9aac",color:"#b3a721"}},naturreservat:{ids:["NR","NRS"],style:{fillColor:"#ef9874",color:"#ef9873"}}},q="#72B026",r="#38A9DC",s={fillcolor:r,circle:!1,thumbnail:!0},t={difo:"Digitalt fortalt",Kulturminnesok:"Kulturminnesok",DiMu:"DigitaltMuseum",MUSIT:"Musit",Artsdatabanken:"Artsdatabanken",wikipedia:"wikipedia",riksantikvaren:"riksantikvaren"};a.datasets={"Digitalt fortalt":{fillcolor:"#F69730",circle:!1,thumbnail:!0},Kulturminnesok:{fillcolor:"#436978",circle:!1,thumbnail:!1},DigitaltMuseum:{fillcolor:"#436978",circle:!1,thumbnail:!1},Musit:{fillcolor:"#436978",circle:!1,thumbnail:!1},Artsdatabanken:{fillcolor:"#5B396B",thumbnail:!1,circle:!0},riksantikvaren:{fillcolor:"#436978",circle:!1,thumbnail:!0},verneomraader:{fillcolor:function(a){if(a){var c=b(a);if(c)return c.style.fillColor}return"#009300"},bordercolor:function(a){if(a){var c=b(a);if(c)return c.style.color}return"#009300"},thumbnail:!1,circle:!0},wikipedia:{fillcolor:"#D14020",thumbnail:!0}},a.groups={},a.getDatasetStyle=function(b){var c=a.datasets[t[b]];return c||(c=a.datasets[b]),c},a.setDatasetStyle=function(b,c){_.has(t,b)||(t[b]=b);var d=a.getDatasetStyle(b);d||(d=s),a.datasets[t[b]]=_.extend({},d,c)};var u={"#F69730":"orange","#38A9DC":"blue","#A23336":"darkred","#72B026":"green","#436978":"cadetblue","#5B396B":"darkpurple","#728224":"darkgreen","#D252B9":"purple","#D14020":"red"};a.getClusterIcon=function(a,b){var c,d=a.getAllChildMarkers(),f=_.uniq(_.map(d,function(a){return a.feature.properties.groupId})),i=h(d[0].feature);if(_.compact(f).length>1){var j=_.compact(f);j.length>1&&(c=_.map(j,_.compose(e,g)))}else c=e(i,d[0].feature);if(b&&(c=q),i.thumbnail){var k=n(d,c,b);if(k)return k}return o(d,c)},a.getIcon=function(a,b){var c=h(a),d=b?q:e(c,a),g=b?q:f(c,a);if(c.thumbnail){var j=m(a,g,b);if(j)return j}return c.circle?i(g,d,c.radius):k(d)},a.getMarker=function(b,c){var d=h(b);if(d.thumbnail){var g=m(b,f(d,b),!1);if(g)return l(b,c,g)}return d.circle?j(c,f(d,b),e(d,b)):l(b,c,a.getIcon(b,!1))},a.colorForFeature=function(a,b,d){var f=h(a);return f?b?e(f,a,d):c(e(f,a)):void 0},a.colorForDataset=function(b,d,f){var g,i;return b.grouped?(g=a.groups[KR.Util.stamp(b)],g||(i=b.datasets[0].extras.datasetId)):(i||(i=b.extras.datasetId),g=h({properties:{datasetId:i}})),g?d?e(g,null,f):c(e(g,null)):void 0},a.getPathStyle=function(a,b){b=b||!1;var c=h(a),d=e(c,a),g=f(c,a);return{weight:1,color:g,fillColor:d,clickable:b,opacity:.8,fillOpacity:.4}},a.getPathStyleForGroup=function(b,c){var d={properties:{groupId:b}};return a.getPathStyle(d,c)}}(KR.Style);var KR=this.KR||{};KR.PathTracer=function(a,b,c){"use strict";function d(b,c){Cesium.Math.setRandomNumberSeed(3),a.clock.startTime=b.clone(),a.clock.stopTime=c.clone(),a.clock.currentTime=b.clone(),a.clock.clockRange=Cesium.ClockRange.LOOP_STOP,a.clock.multiplier=l,a.clock.shouldAnimate=!1}function e(b,c,d){var e=a.entities.add({availability:new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({start:b,stop:c})]),position:d,orientation:new Cesium.VelocityOrientationProperty(d)});return e}function f(a,b,c){b=b.reverse(),c.geometry.coordinates=c.geometry.coordinates.reverse();var d=0,e=turf.point(c.geometry.coordinates[0]),f=new Cesium.SampledPositionProperty;return _.each(b,function(b,g){var h=turf.point(c.geometry.coordinates[g]);d+=1e3*turf.distance(e,h,"kilometers"),e=h;var i=Cesium.JulianDate.addSeconds(a,d/k,new Cesium.JulianDate),j=new Cesium.Cartesian3(b.x,b.y,b.z+2);f.addSample(i,j)}),f}function g(b){a.clock.onTick.addEventListener(function(c){if(m){var d=Cesium.Cartesian3,e=b.position.getValue(c.currentTime,new d),f=b.position.getValue(Cesium.JulianDate.addSeconds(c.currentTime,1/60,new Cesium.JulianDate),new d),g=d.subtract(f,e,new d);d.normalize(g,g);var h=new d,i=new d,j=new d;Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(e,h),d.cross({x:0,y:0,z:1},h,i),d.cross(h,i,j);var k=new d;k.x=d.dot(g,i),k.y=d.dot(g,j),k.z=d.dot(g,h);var l=new d(0,0,1),o=new d(1,0,0),p=new d(0,1,0),q=d.dot(k,o),r=d.dot(k,p),s=d.dot(k,l),t=Math.atan2(q,r),u=Math.asin(s);t+=0*Math.PI,u+=-20/180*Math.PI;var v=800,w=new Cesium.HeadingPitchRange(t,u+n,v);a.scene.camera.lookAt(b.position.getValue(c.currentTime),w)}})}function h(){var h=c.features[0],i=1e3*turf.lineDistance(h,"kilometers"),j=i/k,l=Cesium.JulianDate.fromDate(new Date(2015,2,25,16)),m=Cesium.JulianDate.addSeconds(l,j,new Cesium.JulianDate);d(l,m);var n=f(l,b,h),o=e(l,m,n);o.position.setInterpolationOptions({interpolationDegree:5,interpolationAlgorithm:Cesium.LagrangePolynomialApproximation}),a.trackedEntity=void 0,g(o)}function i(){m=!0,a.clock.shouldAnimate=!0}function j(){m=!1,a.clock.shouldAnimate=!1}var k=1.4,l=35,m=!1,n=0;return h(),{start:i,stop:j,isRunning:function(){return m},setPitchCorr:function(a){n=a}}};var KR=this.KR||{};KR.CesiumMap=function(a,b,c){"use strict";function d(a){return a=a||"//assets.agi.com/stk-terrain/world",new Cesium.CesiumTerrainProvider({url:a,requestVertexNormals:!0,requestWaterMask:!1})}function e(a){var b,c=s.scene.camera;c.moveEnd.addEventListener(function(){var d=Cesium.Ellipsoid.WGS84.cartesianToCartographic(c.position),e=!Cesium.Rectangle.contains(a,d);e&&b&&(c.position=b),b=c.position.clone()})}function f(){s=new Cesium.Viewer(a,t.cesiumViewerOpts);var b=s.scene;b.imageryLayers.removeAll();var f=b.globe;t.cesiumViewerOpts.enableLighting&&(f.enableLighting=!0),f.depthTestAgainstTerrain=!0,s.terrainProvider=d(t.cesiumViewerOpts.terrainUrl);var g,h=b.camera;if(c){c=KR.Util.splitBbox(c);var i=Cesium.Ellipsoid.WGS84;g=new Cesium.Rectangle(Cesium.Math.toRadians(c[0]),Cesium.Math.toRadians(c[1]),Cesium.Math.toRadians(c[2]),Cesium.Math.toRadians(c[3])),h.viewRectangle(g,i)}g&&t.cesiumViewerOpts.limitBounds&&e(g)}function g(a,b){var c=a.features[0].geometry.coordinates,d=_.map(c,function(a){return new Cesium.Cartographic.fromDegrees(a[0],a[1])}),e=Cesium.sampleTerrain(s.terrainProvider,14,d);Cesium.when(e,function(a){b(Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(a))})}function h(a){return _.map(a,function(a,b){return b+"="+a}).join("&")}function i(a){return new Cesium.UrlTemplateImageryProvider({url:a})}function j(a,b,c){var d={SERVICE:"WMTS",REQUEST:"GetTile",TILEROW:"{TileRow}",TILECOL:"{TileCol}",STYLE:"{Style}",LAYER:b};return{url:a+"?"+h(_.extend({},d,c||{})),layer:"",tileMatrixSetID:""}}function k(a,b,c){var d={style:"default",version:"1.0.0",format:"image/png",maximumLevel:19};return new Cesium.WebMapTileServiceImageryProvider(_.extend({},d,j(a,b,c)))}function l(a,b){return new Cesium.WebMapServiceImageryProvider({url:a,layers:b,parameters:{service:"WMS",version:"1.1.1",request:"GetMap",styles:"",format:"image/png",transparent:!0}})}function m(a){return _.map(a,function(a){var b={position:Cesium.Cartesian3.fromDegrees(a.pos.lng,a.pos.lat,a.pos.height||80),billboard:{image:a.icon,show:!0,heightReference:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1},label:{text:a.text,font:"14pt monospace",style:Cesium.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,pixelOffset:new Cesium.Cartesian2(0,32)},properties:a.properties};return s.entities.add(b),b})}function n(a,b,c,d){c=c||14;var e=[];d||(d=0),_.each(a.features,function(a){var b=a.geometry.coordinates;e.push(new Cesium.Cartographic.fromDegrees(b[0],b[1]))});var f=Cesium.sampleTerrain(s.terrainProvider,c,e);Cesium.when(f,function(c){var e=c;_.each(a.features,function(a,b){var c=e[b];a.geometry.coordinates=[Cesium.Math.toDegrees(c.longitude),Cesium.Math.toDegrees(c.latitude),c.height+d]}),b(a)})}function o(a){var b=new Cesium.EntityCollection,c=new Cesium.ScreenSpaceEventHandler(s.scene.canvas);c.setInputAction(function(c){var d=s.scene.drillPick(c.position);if(Cesium.defined(d)){b.removeAll();var e=_.map(d,function(a){var c=a.id;return b.add(c),c.properties});e.length&&a(e)}},Cesium.ScreenSpaceEventType.LEFT_CLICK)}function p(a,b,c,d){c.getBbox(a,b,function(a){n(a,function(a){var b=Cesium.GeoJsonDataSource.load(a);d(b)})},function(a){d()})}function q(a,b,c,d){c.getBbox(a,b,function(a){_.each(a.features,function(a){a.properties=_.extend(a.properties,d)}),n(a,function(a){var b=_.map(a.features,function(a){var b=a.properties["marker-color"]||"blue";return{pos:{lat:a.geometry.coordinates[1],lng:a.geometry.coordinates[0],height:a.geometry.coordinates[2]},icon:"../common/img/markers/"+b+".png",properties:a.properties}});m(b)})},function(b){console.warn("could not load dataset",a)})}function r(){$(".spinner-wrapper").delay(2e3).fadeOut({duration:200})}Cesium.BingMapsApi.defaultKey="";var s,t={cesiumViewerOpts:_.extend({timeline:!1,baseLayerPicker:!1,geocoder:!1,enableLighting:!0,infoBox:!1,animation:!1,orderIndependentTranslucency:!1},b||{})};return f(),{viewer:s,addMarkers:m,build3DLine:g,addClickhandler:o,loadDataset:p,loadDataset2:q,stopLoading:r,getTiles:i,getWmts:k,getWms:l,addImageryProvider:function(a){s.imageryLayers.addImageryProvider(a)}}},KR.CesiumUtils={},KR.CesiumUtils.getBounds=function(a){"use strict";var b=turf.envelope(a),c=b.geometry.coordinates[0];return c[0].concat(c[2]).join(",")};var KR=this.KR||{};KR.CesiumSidebar=function(a,b,c,d){"use strict";function e(a){o.html(a)}function f(a){return{properties:a,template:a.template}}function g(a){p.showFeature(f(a))}function h(a){var b=_.map(a,f);p.showFeatures(b)}function i(b){a.show("slide",{direction:"left"},100),1===b.length?g(b[0]):h(b)}function j(){a.hide("slide",{direction:"left"},100),e(""),q&&q()}d=d||{footerTemplate:_.template($("#footer_template").html()),listElementTemplate:_.template($("#list_item_template").html()),markerTemplate:_.template($("#marker_template").html()),thumbnailTemplate:_.template($("#thumbnail_template").html())};var k=$('');a.append(k);var l=$('');k.append(l);var m=$('×');l.append(m);var n=$("");l.append(n);var o=$('');k.append(o);var p=new KR.SidebarContent(k,o,n,d),q=c;return a.addClass("knreise-sidebar"),m.click(j),{show:i,addCloseCb:function(a){q=a}}};var KR=this.KR||{};!function(){"use strict";function a(){function a(a){if(d&&d.userPosition){var b=turf.point([d.userPosition.lng,d.userPosition.lat]),c=KR.Util.distanceAndBearing(b,a),e=c.distance;return e=1e3>e?KR.Util.round(e,0)+" Meter":KR.Util.round(e/1e3,2)+" Kilometer",{dist:e,rot:c.bearing-45}}}function b(){if(e&&d&&d.userPosition&&f){g&&g.remove();var b=e.find("h3").eq(0),c=a(f);g=$(h({distanceBearing:c})),b.length?b.after(g):e.prepend(g)}}function c(a,c){e=c,f=a,b()}var d,e,f,g,h=_.template($("#user_position_template").html());return{setMap:function(a){d=a,d.on("locationChange",b)},selectFeature:c}}KR.SidebarContent=function(b,c,d,e){function f(a){c.html(a)}function g(a){a&&c.swipe({swipe:function(){},allowPageScroll:"vertical"}).off("swipeLeft").on("swipeLeft",function(){a.next&&a.next()}).off("swipeRight").on("swipeRight",function(){a.prev&&a.prev()})}function h(a,b,c,d,f,g){var i;b>0&&(i=function(e){e&&e.preventDefault(),b-=1,a=f[b];var i=h(a,b,c,d,f,g);j(a,c,d,i,b,f.length)});var l;return b"+a.properties.title+""),p+='',f(p),void i(a,function(b){b.properties=_.extend(a.properties,b.properties),j(b,h,null,k,n,o)})}h=h||a.template||KR.Util.templateForDataset(a.properties.dataset)||l;var q=a.properties.images;_.isArray(q)&&(q=q[0]),a.properties.images||(a.properties.images=null),a.properties.allProps&&a.properties.allProps.europeana_rights?a.properties.license=a.properties.allProps.europeana_rights[0]:a.properties.license=a.properties.license;var r=a.properties.color||KR.Style.colorForFeature(a,!0,!0),p=''+a.properties.provider+"";if(p+=h(_.extend({image:null},a.properties)),e.footerTemplate&&a.properties.link&&(p+=e.footerTemplate(a.properties)),p=$(["",p,"
"].join(" ")),KR.Util.isInIframe()&&p.find("a").attr("target","_blank"),m.selectFeature(a,p),f(p),g(k),b.find(".prev-next-arrows").remove(),d.html(""),k){var s=$('');d.append(s),s.click(k.close);var t=n+1;d.append($(''+t+" av "+o+"
"));var u=$('');b.append(u),k.prev&&u.click(k.prev).addClass("active");var v=$('');b.append(v),k.next&&v.click(k.next).addClass("active")}var w=c.find(".media-container");w.length&&KR.MediaCarousel.SetupMediaCarousel(w),"undefined"!=typeof audiojs&&audiojs.createAll(),c.scrollTop(0)}function k(a,b,f,g,j){g=void 0===g?e.noListThreshold:g;var k=a.length<=g;if(k&&j!==!0){var l=a[0];c.html("");var m=h(l,0,b,f,a);return void this.showFeature(l,b,f,m,0,a.length)}var n=$(''+a.length+"");d.html(n);var o=_.chain(a).groupBy(function(a){return a.properties.provider}).map(function(c,d){var e=$(""),g=$(''),h=_.map(c,function(c){var d=_.findIndex(a,function(a){return a===c});return i(c,d,b,f,a)},this);return g.append(h),e.append('
'+d+"
"),e.append(g),e}).value();c.html(o),c.scrollTop(0)}var l=KR.Util.getDatasetTemplate("popup"),m=new a;return c=$(c),b=$(b),d=$(d),{showFeature:j,showFeatures:k,setMap:function(a){m.setMap(a)}}}}();var KR=this.KR||{};KR.DatasetLoader=function(a,b,c,d,e,f){"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f,unclusterThreshold:a.unclusterThreshold}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()
g&&y("down"),c.on("dataloadend",x),KR.Util.checkThresholdPassed(d,g,y),c.on("click",r),d.on("layerDeselect",p),_.has(b,"showEnkeltminner")&&(i=b.showEnkeltminner),i&&t(b)};return{initKulturminnePoly:z}}}(KR.Config);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getDatasetList=function(b,c,d){var e=a.getKulturminneFunctions(b);c&&3===c.length&&(c="0"+c);var f={difo:{name:"Digitalt fortalt",dataset:{dataset:"difo",api:"norvegiana"},cluster:!0,template:KR.Util.getDatasetTemplate("digitalt_fortalt"),noListThreshold:1/0,description:"Kulturrådets tjeneste for personlige fortellinger fra kulturinstitusjoner og privatpersoner.",allowTopic:!0,feedbackForm:!0,isStatic:!1},verneomr:{id:"verneomraader",dataset:{api:"cartodb",table:"naturvernomrader_utm33_2",columns:["iid","omradenavn","vernef_id","verneform"]},provider:"Naturbase",name:"Verneområder",
+template:KR.Util.getDatasetTemplate("verneomraader"),getFeatureData:function(a,c){b.getItem({api:"norvegiana",id:"kulturnett_Naturbase_"+a.properties.iid},c)},toPoint:{showAlways:!0,stopPolyClick:!0,minSize:20},minZoom:10,cluster:!1,description:"Nasjonalparker og andre naturvernområder - ca. 2700 i hele landet."},artobs:{name:"Artsobservasjoner",hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"Artsdatabanken"},cluster:!1,description:"Artsobservasjoner fra Artsdatabanken",template:KR.Util.getDatasetTemplate("popup")},folketelling:{name:"Folketelling 1910",provider:"Folketelling 1910",dataset:{api:"folketelling",dataset:"property"},isStatic:!1,minZoom:14,template:KR.Util.getDatasetTemplate("folketelling"),getFeatureData:function(a,c){b.getData({api:"folketelling",type:"propertyData",propertyId:a.properties.efid},function(b){a.properties=b.properties,a.properties.provider="Folketelling 1910",c(a)})},mappings:{title:"gaardsnavn_gateadr"},noListThreshold:0,description:"Personer og eiendommer fra folketellingen 1910"},ark_hist:{grouped:!0,name:"Arkeologi og historie",minZoom:14,datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly}],description:"Data fra Universitetsmuseene, Digitalt museum og Riksantikvaren"},jernbane:{id:"jernbane",dataset:{api:"jernbanemuseet"},provider:"Jernbanemuseet",name:"Jernbanemuseet",hideFromGenerator:!0,template:KR.Util.getDatasetTemplate("jernbanemuseet"),getFeatureData:function(a,c){b.getItem({api:"jernbanemuseet",id:a.properties.id},c)},isStatic:!0,bbox:!1,description:"Jernbanemuseet"},arkeologi:{grouped:!0,name:"Arkeologi",minZoom:14,style:{fillcolor:"#436978",circle:!1,thumbnail:!0},datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER regex(?loccatlabel, "^Arkeologisk", "i") .',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly}],description:"Arkeologidata fra Universitetsmuseene og Riksantikvaren"},historie:{grouped:!0,name:"Historie",minZoom:14,style:{fillcolor:"#D252B9",circle:!1,thumbnail:!0},datasets:[{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER (!regex(?loccatlabel, "^Arkeologisk", "i"))',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"-dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Industrimuseum"},isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Foto-SF"},isStatic:!1,bbox:!1,template:KR.Util.getDatasetTemplate("foto_sf")},{dataset:{api:"norvegiana",dataset:"Kystreise"},isStatic:!0,bbox:!1}],description:"Historie og kulturminner fra Riksantikvaren og Digitalt museum "},kunst:{grouped:!0,name:"Kunst",style:{fillcolor:"#72B026",circle:!1,thumbnail:!0},datasets:[{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1}],description:"Kunstdata fra Digitalt museum "},wikipedia:{name:"Wikipedia",provider:"Wikipedia",dataset:{api:"wikipedia"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra bokmålswikipedia"},wikipediaNN:{name:"Wikipedia Nynorsk",provider:"Wikipedia Nynorsk",dataset:{api:"wikipediaNN"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra nynorskwikipedia"},lokalwiki:{id:"lokalwiki",name:"Lokalhistoriewiki",hideFromGenerator:!1,provider:"Lokalhistoriewiki",dataset:{api:"lokalhistoriewiki"},style:{thumbnail:!0},minZoom:13,bbox:!0,isStatic:!1,description:"Stedfestede artikler fra lokalhistoriewiki.no"},riksantikvaren:{id:"riksantikvaren",name:"Kulturminnesøk",hideFromGenerator:!1,provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,unclusterThreshold:13,init:e.initKulturminnePoly,description:"Data fra Riksantikvarens kulturminnesøk"},brukerminner:{name:"Kulturminnesøk - brukerregistreringer",hideFromGenerator:!1,provider:"riksantikvaren",dataset:{api:"kulturminnedata",layer:2,getExtraData:!0,extraDataLayer:6,matchId:"KulturminnesokID"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Brukerregistrerte data fra Riksantikvarens kulturminnesøk",template:KR.Util.getDatasetTemplate("brukerminne")},groruddalen:{name:"Byantikvaren Oslo - Groruddalen",hideFromGenerator:!0,provider:"Byantikvaren i Oslo",dataset:{api:"cartodb",table:"byantikvaren_oslo_groruddalen"},bbox:!1,isStatic:!1,style:{thumbnail:!0},template:KR.Util.getDatasetTemplate("byantikvaren_oslo"),description:"Byantikvarens Groruddalsatlas"},norgerundt:{name:"Norge Rundt",hideFromGenerator:!0,provider:"NRK",dataset:{api:"cartodb",table:"nrk_norge_rundt"},bbox:!1,isStatic:!1,style:{thumbnail:!0},description:"Stedfestede innslag fra Norge Rundt"},dimu:{name:"Digitalt Museum",hideFromGenerator:!1,provider:"dimu",dataset:{dataset:"DiMu",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Digitalt Museum",allowTopic:!0,feedbackForm:!0},musit:{name:"Universitetsmuseene",hideFromGenerator:!1,provider:"Universitetsmuseene",dataset:{dataset:"MUSIT",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Universitetsmuseene",allowTopic:!0,feedbackForm:!0},industrimuseum:{name:"Industrimuseum",hideFromGenerator:!1,provider:"Industrimuseum",dataset:{dataset:"Industrimuseum",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Industrimuseum",allowTopic:!0,feedbackForm:!0},kystreise:{name:"Kystreise",hideFromGenerator:!1,provider:"Kystreise",dataset:{dataset:"Kystreise",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Kystreise",allowTopic:!0,feedbackForm:!0},dimufoto:{hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"DiMu",query:"europeana_type_facet:IMAGE"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,style:{thumbnail:!0},noListThreshold:1/0},kulturminnesok_flickr:{name:"Kulturminnesøk",dataset_name_override:"Kulturminnesøk",provider:"Kulturminnesøk Flickr",hideFromGenerator:!0,dataset:{api:"flickr",group_id:"1426230@N24"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!0,style:{thumbnail:!0},description:"Bilder fra Kulturminnesøks Flickr-gruppe"},riksarkivet:{name:"Riksarkivet",dataset_name_override:"Riksarkivet",provider:"riksarkivet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_archives_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Riksarkivets Flickr-konto"},nasjonalbiblioteket:{name:"Nasjonalbiblioteket",dataset_name_override:"Nasjonalbiblioteket",provider:"nasjonalbiblioteket",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_library_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalbibliotekets Flickr-konto"},oslobyarkiv:{name:"Oslo Byarkiv",dataset_name_override:"Oslo Byarkiv",provider:"oslobyarkiv",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"byarkiv"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Oslo byarkiv sin Flickr-konto"},nasjonalmuseet:{name:"Nasjonalmuseet",dataset_name_override:"Nasjonalmuseet",provider:"nasjonalmuseet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nasjonalmuseet"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalmuseet sin Flickr-konto"},nve:{name:"NVE",dataset_name_override:"NVE",provider:"nve",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nve",accuracy:"6"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra NVE Flickr-konto"},vestfoldmuseene:{name:"Vestfoldmuseene",dataset_name_override:"Vestfoldmuseene",provider:"Vestfoldmuseene",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"vestfoldmuseene",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Vestfoldmuseene sin Flickr-konto"},perspektivet:{name:"Perspektivet Museum",dataset_name_override:"Perspektivet Museum",provider:"Perspektivet Museum",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"perspektivetmuseum",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Perspektivet Museum sin Flickr-konto"}};if(!c&&!d){var g={bbox:!0,minZoom:12,isStatic:!1,bboxFunc:KR.Util.sparqlBbox};_.extend(f.riksantikvaren,g),_.extend(f.ark_hist.datasets[2],g),_.extend(f.arkeologi.datasets[1],g),_.extend(f.historie.datasets[0],g)}return f},a.getDatasets=function(b,c,d,e){var f=a.getDatasetList(c,d,e);return _.chain(b).map(function(a){var b;if(a.indexOf(":")>-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};!function(a){"use strict";function b(a){return turf.featurecollection([turf.simplify(a.features[0],.001,!1)])}function c(a,b){return b=b||{},{polyline:{positions:a,width:5,material:new Cesium.PolylineOutlineMaterialProperty({color:Cesium.Color.ORANGE,outlineWidth:2,outlineColor:Cesium.Color.BLACK})}}}function d(a,b,c){var d=a.layer||"topo2";if("norges_grunnkart_graatone"===d&&(d="norges_grunnkart"),"hist"===d)c(b.getWms("http://wms.geonorge.no/skwms1/wms.historiskekart","historiskekart"));else if("nib"===d){var e="http://knreise.no/nib/?type=token";KR.Util.sendRequest(e,null,function(a){c(0!==a.indexOf("**")?b.getWmts("http://crossorigin.me/http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts","NiB",{TILEMATRIXSET:"EPSG:900913",TILEMATRIX:"EPSG:900913:{TileMatrix}",FORMAT:"image/jpeg",GKT:a}):b.getTiles("http://www.webatlas.no/wacloud/servicerepository/combine.aspx?X={x}&Y={y}&Z={z}&layers=TMS_WEBATLAS_STANDARD:1"))})}else c(b.getWmts("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts",d,{TILEMATRIXSET:"EPSG:3857",TILEMATRIX:"EPSG:3857:{TileMatrix}",FORMAT:"image/png"}))}function e(a){function b(){e.find(".glyphicon").removeClass("glyphicon-play").addClass("glyphicon-pause"),a.start()}function c(){e.find(".glyphicon").removeClass("glyphicon-pause").addClass("glyphicon-play"),a.stop()}function d(){a.isRunning()?c():b()}var e=$("#playpause");return{play:b,pause:c,toggle:d}}var f={animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,navigationHelpButton:!0,navigationInstructionsInitiallyVisible:!1,orderIndependentTranslucency:!1};a.setupMap3d=function(a,g,h){function i(){var b=KR.Config.getDatasets(g,a);return _.chain(b).map(function(a){return a.datasets?a.datasets:a}).flatten().filter(function(a){return _.has(a.dataset,"kommune")&&_.isUndefined(a.dataset.kommune)?!1:!0}).value()}function j(a,b){return new KR.CesiumMap(a,_.extend(f,{limitBounds:h.limitBounds,terrainUrl:h.terrainUrl,enableLighting:h.enableLighting}),b)}function k(b,c,d){_.each(b,function(b){var d=KR.Util.getDatasetId(b),e={template:b.template,datasetId:d,"marker-color":KR.Style.colorForFeature({properties:{datasetId:d}},!1)};o.loadDataset2(b.dataset,c,a,e)}),o.addClickhandler(function(a){q.show(a),d&&d()})}function l(a){o=j("cesium-viewer",a),o.viewer.scene.imageryLayers.removeAll(),d(h,o,o.addImageryProvider),k(i(),a),o.stopLoading()}function m(){var f,g,l=!1;KR.Util.getLine(a,h.line,function(a){if(p=KR.CesiumUtils.getBounds(a),o=j("cesium-viewer",p),d(h,o,o.addImageryProvider),k(i(),p,function(){h.player&&(l=f.isRunning(),g.pause(),f.stop())}),o.build3DLine(a,function(a){var b=c(a,{color:Cesium.Color.DEEPSKYBLUE,glow:.25});o.viewer.zoomTo(o.viewer.entities.add(b)),o.stopLoading()}),h.player){var m=b(a);o.build3DLine(m,function(a){f=new KR.PathTracer(o.viewer,a,m),f.setPitchCorr(.1),g=new e(f),$("#playpause").removeClass("hidden"),$("#playpause").click(g.toggle)}),q.addCloseCb(function(){l&&g.play()})}})}function n(){h.bbox?l(h.bbox):h.komm?a.getMunicipalityBounds(h.komm,l):h.line?m():alert("Missing parameters!")}h=h||{},h=_.extend({player:!0,limitBounds:!1},h);var o,p,q=KR.CesiumSidebar($("#cesium-sidebar"),{});n()}}(KR);
\ No newline at end of file