com.mware.web.product.map.dist.geoShapePreview.js Maven / Gradle / Ivy
The newest version!
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require(!1),require(!1),require(!1),require(!1),require(!1),require(!1)):"function"==typeof define&&define.amd?define(["openlayers","util/withDataRequest","jscache","util/vertex/formatters","util/mapConfig","public/v1/api"],t):"object"==typeof exports?exports.geoShapePreview=t(require(!1),require(!1),require(!1),require(!1),require(!1),require(!1)):e.geoShapePreview=t(e[void 0],e[void 0],e[void 0],e[void 0],e[void 0],e[void 0])}("undefined"!=typeof self?self:this,function(e,t,r,n,o,i){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=191)}({0:function(t,r){t.exports=e},10:function(e,r){e.exports=t},11:function(e,t){e.exports=r},12:function(e,t){e.exports=n},19:function(e,t){e.exports=o},191:function(e,t,r){var n,o;n=[r(192),r(0),r(4),r(19),r(12)],void 0!==(o=function(e,t,r,n,o){"use strict";function i(){this.attributes({ignoreUpdateModelNotImplemented:!0}),this.before("initialize",function(e,t){this.element=t.model}),this.after("initialize",function(){this.setupMap()}),this.setupMap=function(){var e=this,i=r.byType,s=i.vectorXhr,u=i.tile,c=n(),l=c.source,f=c.sourceOptions,d=u.configure("base",{source:l,sourceOptions:f}),g=d.layer,v=s.configure(this.element.id,{id:this.element.id,element:this.element,propName:ONTOLOGY_CONSTANTS.PROP_RAW,propKey:"",mimeType:o.vertex.prop(this.element,ONTOLOGY_CONSTANTS.PROP_MIME_TYPE),sourceOptions:{wrapX:!1}}),h=v.source,p=v.layer,y=new t.Map({target:this.node,layers:[g,p],controls:[new t.control.Zoom],view:new t.View({zoom:2,minZoom:1,center:[0,0]})});this.geoShapeLayer=p,this.map=y;var m=a[this.element.id]||s.loadFeatures(h,p);Promise.resolve(m).then(function(t){var r=e.map.getView(),n=e.geoShapeLayer.getSource();n.addFeatures(t),e.geoShapeLayer.set("status","loaded"),r.fit(n.getExtent()),a[e.element.id]||(a[e.element.id]=t)})},this.onDetailPaneResize=function(){this.map&&this.map.updateSize()}}var a={};return e.defineComponent(i)}.apply(t,n))&&(e.exports=o)},192:function(e,t){e.exports=i},4:function(e,t,r){function n(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}var o,i,a=function(){function e(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(o)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],r=e.visible,o=void 0===r||r,i=e.opacity,a=void 0===i?1:i,s=e.zIndex,u=void 0===s?0:s,c=n(e,["visible","opacity","zIndex"]);_.mapObject(c,function(e,r){null===e?t.unset(r):t.set(r,e)}),t.setVisible(o),t.setOpacity(a),t.setZIndex(u)}function c(t,r,i){var a=t.features,u=r.source,c=_.indexBy(u.getFeatures(),function(e){return e.getId()}),l=[],f=!1;if(a)for(var g=0;g=0;t--)if(_.isFunction(e[t].getImage)){var r=e[t].getImage(),n=r&&_.isFunction(r.getRadius)&&r.getRadius();if(n){var o=n/devicePixelRatio;return o}}}var g="org-bigconnect-map-vector-selected-overlay",v={sortable:!0,toggleable:!0},h={tile:{configure:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.source,i=r.sourceOptions,a=void 0===i?{}:i,u=n(r,["source","sourceOptions"]),c=void 0;if(!(o in e.source&&_.isFunction(e.source[o])))throw console.error("Unknown map provider type: ",o),new Error("map.provider is invalid");return c=new e.source[o](s({crossOrigin:"anonymous"},a)),{source:c,layer:new e.layer.Tile(s({},v,{id:t,label:"Base",type:"tile",sortable:!1,source:c},u))}},addEvents:function(e,t,r){return[t.source.on("tileloaderror",function(e){var t=e.tile;t&&(t._retryCount=(t._retryCount||0)+1,t._retryCount<=3&&(console.warn("Tile error retry: "+t._retryCount+" of 3",t.src_),_.defer(function(){t.load()})))})]}},cluster:{configure:function(r){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=new e.source.Vector({features:[]}),u=new t({source:a}),c=new e.layer.Vector(s({},v,{id:r,label:"Cluster",type:"cluster",style:function(e){return n.style(e,{source:a})},source:u},i)),l=new e.layer.Heatmap(s({},v,i,{visible:!1,id:"heatmap_cluster",label:"Heatmap",type:"cluster_heatmap",source:a}));return o.clear(),{source:a,clusterSource:u,layers:[l,c]}},style:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.source,n=t.selected,o=void 0!==n&&n,i=e.get("count"),a=e.get("selectionState")||"none",s=o||"none"!==a;return i>1?p.cluster(e,{selected:s,source:r}):p.feature(e.get("features")[0],{selected:s})},addEvents:function(t,r,n){var o=this,i=r.source,s=r.clusterSource,u=r.layers,c=a(u,2),l=c[0],f=c[1],d=function(e){return function(t){var r=t.get("element"),n="vertex"===r.type?"vertices":"edges";e[n].push(r.id)}},g=function(e){if(e.get("count")<2)return!1;var t=e.get("features"),r=t.filter(function(e){return e.get("selected")});return 01&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2],i=new e.source.Vector({features:[],wrapX:!1});if(n.getExtent){var a=i.getExtent;i.getExtent=function(){var t=a&&a.apply(this,arguments),r=n.getExtent(o,i,t);return e.extent.isEmpty(r)?t||e.extent.createEmpty():r||t||e.extent.createEmpty()}}var u=new e.layer.Vector(s({},v,{id:t,type:"ancillary",sortable:!1,toggleable:!1,source:i,renderBuffer:500,updateWhileInteracting:!0,updateWhileAnimating:!0,style:function(e){return r.style(e)}},n));return{source:i,layer:u}},style:function(e){var t=e.get("styles");if(t){var r=t.normal;if(r.length)return r}},update:c},vectorXhr:{configure:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.sourceOptions,i=void 0===o?{}:o,a=n(r,["sourceOptions"]),u=new e.source.Vector(i);return{source:u,layer:new e.layer.Vector(s({},v,{id:t,type:"vectorXhr",source:u},a))}},addEvents:function(t,r,n){var o=r.source,i=r.layer,a={vertices:[],edges:[]},s=i.get("element"),u="vertex"===s.type?"vertices":"edges",c=f(i);return a[u].push(s.id),[t.on("click",function(e){var t=e.map,r=e.pixel,i=t.getFeaturesAtPixel(r),s=o.getFeatures();i&&(1===i.length&&i[0].getId()===c&&o.getFeatureById(c)?n.onSelectElements({vertices:[],edges:[]}):i.every(function(e){return s.includes(e)})&&n.onSelectElements(a))}),o.on("propertyChange",function(t){if("status"===t.key&&"loaded"===t.target.get(t.key)){var r=o.getFeatureById(c);if(r){var n=void 0;o.forEachFeature(function(t){var r=t.getGeometry(),o=r.getExtent();t.getId()!==c&&(n?e.extent.extend(n,o):n=o)});var i=e.geom.Polygon.fromExtent(n);r.setGeometry(i)}}})]},update:function(t,r){var n=r.source,o=r.layer,i=t.element,a=(t.features,t.selected),s=o.get("status"),u=!1;if(i!==o.get("element")&&(n.set("element",i),u=!0),s){if(a!==n.get("selected")){var c=f(o);if(n.set("selected",a),u=!0,a&&"loaded"===s){var l=void 0;n.forEachFeature(function(t){var r=t.getGeometry(),n=r.getExtent();t.getId()!==c&&(l?e.extent.extend(l,n):l=n)});var d=new e.Feature(e.geom.Polygon.fromExtent(l||[0,0,0,0]));d.setStyle(new e.style.Style({fill:new e.style.Fill({color:[0,136,204,.3]}),stroke:new e.style.Stroke({color:[0,136,204,.4],width:1})})),d.setId(c),n.addFeature(d)}else{var g=n.getFeatureById(c);g&&n.removeFeature(g)}}}else this.loadFeatures(n,o).then(function(e){e&&(n.clear(!0),n.addFeatures(e),o.set("status","loaded"))});return{changed:u}},loadFeatures:function(t,n){var o=n.getProperties(),i=o.id,a=o.element,s=o.propName,u=o.propKey,c=o.mimeType;return n.set("status","loading"),r.dataRequest("vertex","propertyValue",i,s,u).then(function(t){var r=l(c),n=r.readProjection(t);if(n&&e.proj.get(n.getCode())){return r.readFeatures(t,{dataProjection:n,featureProjection:"EPSG:3857"})}throw new Error("unhandledDataProjection")}).then(function(e){return e.map(function(e,t){return e.setId(n.get("id")+":"+t),e.set("element",a),e})}).catch(function(e){var t="unhandledDataProjection"===e.message?i18n("org.bigconnect.web.product.map.MapWorkProduct.layer.error.data.format"):i18n("org.bigconnect.web.product.map.MapWorkProduct.layer.error");n.set("status",{type:"error",message:t})})}}},p={feature:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.selected,n=void 0!==r&&r,i=e.getProperties(),a=i.focused,s=i.focusedDim,u=i.styles,c=i.selected,l=i._nodeRadius,f=n||c,d=!0,g=void 0;if(u){var v=u.normal,h=u.selected,p=void 0;!v.length||f&&h.length?h.length&&f&&(p=h):p=v,p&&(g=_.isArray(p)?p:[p])}else!1,d=!1,g=o.getOrCreateFeature({src:e.get(f?"iconUrlSelected":"iconUrl"),imgSize:e.get("iconSize"),scale:1/e.get("pixelRatio"),anchor:e.get("iconAnchor")},a);return _.isEmpty(g)?(console.warn("No styles for feature, ignoring.",e),[]):d&&a?o.addFocus(l,o.reset(l,g)):s?o.addDim(l,g):o.reset(l,g)},cluster:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.selected,n=void 0!==r&&r,a=t.source,s=(t.clusterSource,e.get("count")),u=e.get("focusStats"),c=e.get("selectionState")||"none",l=e.get("selectionCount")||0,f=a.countStats,d=f.min,g=f.max,v=Math.min(g,Math.max(d,s)),h=d===g?12:i(v,d,g,12,20);return o.getOrCreateCluster({count:s,radius:h,selected:n,selectionState:c,selectionCount:l,focusStats:u})}};return{byType:h,styles:p,setLayerConfig:u}}.apply(t,o))&&(e.exports=i)},7:function(e,t,r){function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t0});c.max=Math.max(p,c.max),c.min=Math.min(p,c.min),t.features.push(t.createCluster(y,h,p))}}(g[v],v)}(i[l])}},t.prototype.createCluster=function(t,r,n){var o={some:0,all:!1,dim:!1};t.forEach(function(e){var t=e.get("focused");o.some+=t?1:0,o.all=o.all&&t,o.dim=o.dim||e.get("focusedDim")});var i=r.reduce(function(e,t){return e.map(function(e,r){return e+t[r]})},[0,0]),a=i.map(function(e){return e/r.length}),s=new e.geom.Point(a);return new e.Feature({geometry:s,features:t,coordinates:r,count:n,focusStats:o})},t}.apply(t,n))&&(e.exports=o)}})});
//# sourceMappingURL=geoShapePreview.js.map