From 42d7109b8d6a966f60188efd5a98c6adc40cc93b Mon Sep 17 00:00:00 2001 From: viatkinviatkin Date: Mon, 9 Oct 2023 15:05:41 +0500 Subject: [PATCH 01/33] RGIS project functionality buttons have been removed from the technology addon --- addon/components/feature-result-item.js | 12 ++---------- addon/components/flexberry-simpledatetime.js | 16 ++++++++++++++-- addon/components/layer-result-list.js | 12 ++---------- .../templates/components/feature-result-item.hbs | 10 ++++------ addon/templates/components/layer-result-list.hbs | 11 +++++++---- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/addon/components/feature-result-item.js b/addon/components/feature-result-item.js index d4b628432..2ca338b23 100644 --- a/addon/components/feature-result-item.js +++ b/addon/components/feature-result-item.js @@ -8,13 +8,14 @@ import { translationMacro as t } from 'ember-i18n'; import openCloseSubmenu from 'ember-flexberry-gis/utils/open-close-sub-menu'; import { zoomToBounds } from '../utils/zoom-to-bounds'; import ResultFeatureInitializer from '../mixins/result-feature-initializer'; +import SlotsMixin from 'ember-block-slots'; /** Component for display GeoJSON feature object details @class FeatureResultItemComponent @extends Ember.Component */ -export default Ember.Component.extend(ResultFeatureInitializer, { +export default Ember.Component.extend(SlotsMixin, ResultFeatureInitializer, { /** Service for managing map API. @@ -600,15 +601,6 @@ export default Ember.Component.extend(ResultFeatureInitializer, { this.sendAction('findIntersection', this.get('feature')); }, - /** - * Action for search satellites - * @method actions.searchSatellites - */ - searchSatellites() { - this.set('isSubmenu', false); - this.sendAction('searchSatellites', this.get('feature')); - }, - /** Add feature to favorites list Action is sended to layer-result-list. diff --git a/addon/components/flexberry-simpledatetime.js b/addon/components/flexberry-simpledatetime.js index a3f705474..f112e65af 100644 --- a/addon/components/flexberry-simpledatetime.js +++ b/addon/components/flexberry-simpledatetime.js @@ -49,9 +49,21 @@ export default SimpleDatetime.extend({ this.set('eventNamespace', namespace); Ember.$(document).on(`mousedown.${namespace}`, e => { let clicky = Ember.$(e.target); - if (clicky.closest('.flatpickr-calendar').length === 0 && clicky.get(0) !== this.$('.custom-flatpickr').get(0)) { - this.get('_flatpickr').close(); + let flatpickr = this.get('_flatpickr'); + + if (!flatpickr) { + return; + } + + if (clicky.closest('.flatpickr-calendar').length > 0) { + return; } + + if (clicky.get(0) === this.$('.custom-flatpickr').get(0)) { + return; + } + + flatpickr.close(); }); this.$('.custom-flatpickr').on('click', (e) => { this.inputClick(this, e); }); this.$('.button').on('click', (e) => { this.actions.remove(this, e); }); diff --git a/addon/components/layer-result-list.js b/addon/components/layer-result-list.js index 09fcff55d..010b0a01c 100644 --- a/addon/components/layer-result-list.js +++ b/addon/components/layer-result-list.js @@ -6,7 +6,7 @@ import Ember from 'ember'; import layout from '../templates/components/layer-result-list'; import LeafletZoomToFeatureMixin from '../mixins/leaflet-zoom-to-feature'; import ResultFeatureInitializer from '../mixins/result-feature-initializer'; - +import SlotsMixin from 'ember-block-slots'; // Url key used to identify transitions from ember-flexberry-gis on other resources. const isMapLimitKey = 'GISLinked'; @@ -17,7 +17,7 @@ const isMapLimitKey = 'GISLinked'; @uses LeafletZoomToFeatureMixin @extends Ember.Component */ -export default Ember.Component.extend(LeafletZoomToFeatureMixin, ResultFeatureInitializer, { +export default Ember.Component.extend(SlotsMixin, LeafletZoomToFeatureMixin, ResultFeatureInitializer, { /** Service for managing map API. @@ -260,14 +260,6 @@ export default Ember.Component.extend(LeafletZoomToFeatureMixin, ResultFeatureIn this.sendAction('showIntersectionPanel', feature); }, - /** - * Search satellite action - * @param feature - */ - searchSatellites(feature) { - this.sendAction('showSatellitePanel', feature); - }, - /** Action adds feature to favorites. diff --git a/addon/templates/components/feature-result-item.hbs b/addon/templates/components/feature-result-item.hbs index 1f63bdfe8..fe0c44197 100644 --- a/addon/templates/components/feature-result-item.hbs +++ b/addon/templates/components/feature-result-item.hbs @@ -1,3 +1,4 @@ +{{yield}}
{{#if _showLoader}}
@@ -113,12 +114,9 @@ {{t "components.feature-result-item.find-intersection-caption"}}
-
- - - {{t "components.feature-result-item.search-satellite"}} - -
+ {{#yield-slot "list-buttons" (block-params feature)}} + {{yield}} + {{/yield-slot}} {{/if}} diff --git a/addon/templates/components/layer-result-list.hbs b/addon/templates/components/layer-result-list.hbs index 2cde784f0..aebf9f5c3 100644 --- a/addon/templates/components/layer-result-list.hbs +++ b/addon/templates/components/layer-result-list.hbs @@ -1,3 +1,4 @@ +{{yield}} {{#if _showLoader}}
{{t "components.layer-result-list.processing"}} {{else if _noData}} @@ -110,7 +111,7 @@ accessibleMap=accessibleMap }} {{else}} - {{feature-result-item + {{#feature-result-item feature=feature resultObject=result highlightable=enableHighlight @@ -124,7 +125,6 @@ zoomTo=(action "zoomTo") clearSelected=(action "clearSelected") findIntersection=(action 'findIntersection') - searchSatellites=(action "searchSatellites") intersection=intersection zoomToIntersection=(action 'zoomToIntersection') panToIntersection=(action 'panToIntersection') @@ -132,6 +132,8 @@ availableEdit=(and availableEdit (array-contains accessibleData result.layerModel.id)) accessibleMap=accessibleMap }} + {{yield}} + {{/feature-result-item}} {{/if}} {{/if}} {{/each}} @@ -243,7 +245,7 @@ accessibleMap=accessibleMap }} {{else}} - {{feature-result-item + {{#feature-result-item feature=feature resultObject=result displayProperty="displayValue" @@ -256,7 +258,6 @@ zoomTo=(action "zoomTo") clearSelected=(action "clearSelected") findIntersection=(action 'findIntersection') - searchSatellites=(action "searchSatellites") intersection=intersection zoomToIntersection=(action 'zoomToIntersection') panToIntersection=(action 'panToIntersection') @@ -268,6 +269,8 @@ availableEdit=(and availableEdit (array-contains accessibleData result.layerModel.id)) accessibleMap=accessibleMap }} + {{yield}} + {{/feature-result-item}} {{/if}} {{/each}} {{#if result.maxResultsLimitOverage}} From 4e7ee522c947308df3c228262c9cb123f02aaf73 Mon Sep 17 00:00:00 2001 From: viatkinviatkin Date: Mon, 9 Oct 2023 15:13:10 +0500 Subject: [PATCH 02/33] jscs fix --- addon/components/layer-result-list.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/components/layer-result-list.js b/addon/components/layer-result-list.js index 010b0a01c..f56c86230 100644 --- a/addon/components/layer-result-list.js +++ b/addon/components/layer-result-list.js @@ -7,6 +7,7 @@ import layout from '../templates/components/layer-result-list'; import LeafletZoomToFeatureMixin from '../mixins/leaflet-zoom-to-feature'; import ResultFeatureInitializer from '../mixins/result-feature-initializer'; import SlotsMixin from 'ember-block-slots'; + // Url key used to identify transitions from ember-flexberry-gis on other resources. const isMapLimitKey = 'GISLinked'; From 0d5f2a85f968aff6a25724d509f95196966bfb6b Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 16 Oct 2023 15:25:20 +0500 Subject: [PATCH 03/33] fix bounds CRS --- addon/components/layers/odata-vector-layer.js | 26 ++++++++++++++++++- addon/components/layers/wfs-layer.js | 21 +++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/addon/components/layers/odata-vector-layer.js b/addon/components/layers/odata-vector-layer.js index 1486be369..0c5f6f076 100644 --- a/addon/components/layers/odata-vector-layer.js +++ b/addon/components/layers/odata-vector-layer.js @@ -1519,7 +1519,31 @@ export default BaseVectorLayer.extend({ let loadedBounds = this.get('loadedBounds'); let leafletMap = this.get('leafletMap'); let obj = this.get('_adapterStoreModelProjectionGeom'); - let bounds = L.rectangle(leafletMap.getBounds()); + + let boundsMap = leafletMap.getBounds(); + if (boundsMap && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { + let crsBounds = leafletObject.options.crs.bounds; + if (boundsMap._northEast.lat > crsBounds.max.x) { + boundsMap._northEast.lat = crsBounds.max.x; + } + + if (boundsMap._northEast.lng > crsBounds.max.y) { + boundsMap._northEast.lng = crsBounds.max.y; + } + + if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) + || (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { + boundsMap._southWest.lat = crsBounds.min.x; + } + + if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) + || (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { + boundsMap._southWest.lng = crsBounds.min.y; + } + } + + let bounds = L.rectangle(boundsMap); + if (!Ember.isNone(leafletObject.showLayerObjects)) { leafletObject.showLayerObjects = false; } diff --git a/addon/components/layers/wfs-layer.js b/addon/components/layers/wfs-layer.js index a373195df..0b96ce676 100644 --- a/addon/components/layers/wfs-layer.js +++ b/addon/components/layers/wfs-layer.js @@ -900,6 +900,27 @@ export default BaseVectorLayer.extend({ let needPromise = false; if (continueLoad && show && checkMapZoom(leafletObject)) { let bounds = leafletMap.getBounds(); + if (bounds && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { + let crsBounds = leafletObject.options.crs.bounds; + if (bounds._northEast.lat > crsBounds.max.x) { + bounds._northEast.lat = crsBounds.max.x; + } + + if (bounds._northEast.lng > crsBounds.max.y) { + bounds._northEast.lng = crsBounds.max.y; + } + + if ((bounds._southWest.lat < 0 && bounds._southWest.lat < crsBounds.min.x) + || (bounds._southWest.lat > 0 && bounds._southWest.lat > crsBounds.min.x)) { + bounds._southWest.lat = crsBounds.min.x; + } + + if ((bounds._southWest.lng < 0 && bounds._southWest.lng < crsBounds.min.y) + || (bounds._southWest.lng > 0 && bounds._southWest.lng > crsBounds.min.y)) { + bounds._southWest.lng = crsBounds.min.y; + } + } + if (!Ember.isNone(leafletObject.showLayerObjects)) { leafletObject.showLayerObjects = false; } From 1a6e6a448e551d0cd870dc2d92b2ca2ae1d0dd6b Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 16 Oct 2023 15:35:53 +0500 Subject: [PATCH 04/33] fix _boundsCrs --- addon/components/base-vector-layer.js | 27 +++++++++++++++++++ addon/components/layers/odata-vector-layer.js | 23 +--------------- addon/components/layers/wfs-layer.js | 23 +--------------- 3 files changed, 29 insertions(+), 44 deletions(-) diff --git a/addon/components/base-vector-layer.js b/addon/components/base-vector-layer.js index 218466220..76b7b9eb0 100644 --- a/addon/components/base-vector-layer.js +++ b/addon/components/base-vector-layer.js @@ -1317,5 +1317,32 @@ export default BaseLayer.extend(layerLabel, { } else { return geoJSONLayer.geometry.coordinates; } + }, + + _boundsCrs(leafletObject) { + let leafletMap = this.get('leafletMap'); + let boundsMap = leafletMap.getBounds(); + if (boundsMap && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { + let crsBounds = leafletObject.options.crs.bounds; + if (boundsMap._northEast.lat > crsBounds.max.x) { + boundsMap._northEast.lat = crsBounds.max.x; + } + + if (boundsMap._northEast.lng > crsBounds.max.y) { + boundsMap._northEast.lng = crsBounds.max.y; + } + + if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) + || (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { + boundsMap._southWest.lat = crsBounds.min.x; + } + + if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) + || (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { + boundsMap._southWest.lng = crsBounds.min.y; + } + } + + return boundsMap; } }); diff --git a/addon/components/layers/odata-vector-layer.js b/addon/components/layers/odata-vector-layer.js index 0c5f6f076..d56ae0148 100644 --- a/addon/components/layers/odata-vector-layer.js +++ b/addon/components/layers/odata-vector-layer.js @@ -1517,30 +1517,9 @@ export default BaseVectorLayer.extend({ if ((continueLoad && show && checkMapZoom(leafletObject)) || (showLayerObjects && continueLoad)) { let loadedBounds = this.get('loadedBounds'); - let leafletMap = this.get('leafletMap'); let obj = this.get('_adapterStoreModelProjectionGeom'); - let boundsMap = leafletMap.getBounds(); - if (boundsMap && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { - let crsBounds = leafletObject.options.crs.bounds; - if (boundsMap._northEast.lat > crsBounds.max.x) { - boundsMap._northEast.lat = crsBounds.max.x; - } - - if (boundsMap._northEast.lng > crsBounds.max.y) { - boundsMap._northEast.lng = crsBounds.max.y; - } - - if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) - || (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { - boundsMap._southWest.lat = crsBounds.min.x; - } - - if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) - || (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { - boundsMap._southWest.lng = crsBounds.min.y; - } - } + let boundsMap = this._boundsCrs(leafletObject); let bounds = L.rectangle(boundsMap); diff --git a/addon/components/layers/wfs-layer.js b/addon/components/layers/wfs-layer.js index 0b96ce676..71aa198cf 100644 --- a/addon/components/layers/wfs-layer.js +++ b/addon/components/layers/wfs-layer.js @@ -891,7 +891,6 @@ export default BaseVectorLayer.extend({ leafletObject = this.returnLeafletObject(); } - let leafletMap = this.get('leafletMap'); if (!Ember.isNone(leafletObject)) { let show = this.get('visibility') || (!Ember.isNone(leafletObject.showLayerObjects) && leafletObject.showLayerObjects); let continueLoad = !leafletObject.options.showExisting && leafletObject.options.continueLoading; @@ -899,27 +898,7 @@ export default BaseVectorLayer.extend({ let needPromise = false; if (continueLoad && show && checkMapZoom(leafletObject)) { - let bounds = leafletMap.getBounds(); - if (bounds && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { - let crsBounds = leafletObject.options.crs.bounds; - if (bounds._northEast.lat > crsBounds.max.x) { - bounds._northEast.lat = crsBounds.max.x; - } - - if (bounds._northEast.lng > crsBounds.max.y) { - bounds._northEast.lng = crsBounds.max.y; - } - - if ((bounds._southWest.lat < 0 && bounds._southWest.lat < crsBounds.min.x) - || (bounds._southWest.lat > 0 && bounds._southWest.lat > crsBounds.min.x)) { - bounds._southWest.lat = crsBounds.min.x; - } - - if ((bounds._southWest.lng < 0 && bounds._southWest.lng < crsBounds.min.y) - || (bounds._southWest.lng > 0 && bounds._southWest.lng > crsBounds.min.y)) { - bounds._southWest.lng = crsBounds.min.y; - } - } + let bounds = this._boundsCrs(leafletObject); if (!Ember.isNone(leafletObject.showLayerObjects)) { leafletObject.showLayerObjects = false; From 1cd1737de9e7752b6ddca94e3e3eea9cbda19624 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 16 Oct 2023 15:43:06 +0500 Subject: [PATCH 05/33] fix jslint --- addon/components/base-vector-layer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addon/components/base-vector-layer.js b/addon/components/base-vector-layer.js index 76b7b9eb0..9976b0d67 100644 --- a/addon/components/base-vector-layer.js +++ b/addon/components/base-vector-layer.js @@ -1332,14 +1332,14 @@ export default BaseLayer.extend(layerLabel, { boundsMap._northEast.lng = crsBounds.max.y; } - if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) - || (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { - boundsMap._southWest.lat = crsBounds.min.x; + if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) || + (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { + boundsMap._southWest.lat = crsBounds.min.x; } - if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) - || (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { - boundsMap._southWest.lng = crsBounds.min.y; + if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) || + (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { + boundsMap._southWest.lng = crsBounds.min.y; } } From acba3a9a9737f22b28c02279b7648b0f46221902 Mon Sep 17 00:00:00 2001 From: Lytkina Darya Date: Wed, 18 Oct 2023 10:10:00 +0500 Subject: [PATCH 06/33] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flexberry-edit-layer-feature.js | 79 +------------------ .../flexberry-layers-attributes-panel.js | 6 ++ addon/mixins/edit-feature.js | 76 ++++++++++++++++++ .../flexberry-maplayer-actions-handler.js | 4 +- 4 files changed, 86 insertions(+), 79 deletions(-) diff --git a/addon/components/flexberry-edit-layer-feature.js b/addon/components/flexberry-edit-layer-feature.js index b87fc08f6..e6f21f3bb 100644 --- a/addon/components/flexberry-edit-layer-feature.js +++ b/addon/components/flexberry-edit-layer-feature.js @@ -4,7 +4,6 @@ import SnapDrawMixin from '../mixins/snap-draw'; import EditFeatureMixin from '../mixins/edit-feature'; import LeafletZoomToFeatureMixin from '../mixins/leaflet-zoom-to-feature'; import { translationMacro as t } from 'ember-i18n'; -import { getLeafletCrs } from '../utils/leaflet-crs'; import { addAlpha, splitColor } from '../utils/leaflet-opacity'; export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, EditFeatureMixin, { @@ -893,81 +892,6 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, } }, - /** - Sends request to trancate GeoWebCache for layer by boundingBox. - - @method trancateGeoWebCache - @param {Object} leafletObject laeflet layer. - */ - trancateGeoWebCache(leafletObject) { - let layers = leafletObject.wmsParams.layers.split(); - let workspace; - let layer; - let geoWebCache; - if (layers.length === 2) { - workspace = layers[0]; - layer = layers[1]; - } else { - let urlSplit = leafletObject._url.split('/'); - let indexGeoserver = urlSplit.indexOf('geoserver'); - if (indexGeoserver > -1 && urlSplit.length === indexGeoserver + 3) { - workspace = urlSplit.at(indexGeoserver + 1); - } else { - console.error('Can\'t get workspace in geoserver'); - return; - } - - layer = layers[0]; - } - - if (!Ember.isBlank(leafletObject._url.match(new RegExp('(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?')))) { - let indexGeoserver = leafletObject._url.indexOf('geoserver'); - if (indexGeoserver === -1) { - console.error('Can\'t get url geoserver'); - return; - } - - geoWebCache = leafletObject._url.slice(0, indexGeoserver + 10) + '/gwc/rest/seed/'; - } - - if (!Ember.isNone(geoWebCache)) { - let url = geoWebCache + workspace + ':' + layer; - let gridSetId = leafletObject.wmsParams.crs + '_' + leafletObject.wmsParams.width; - let leafletMap = this.get('leafletMap'); - let zoom = Math.trunc(leafletMap.getZoom()); - let zoomStart = zoom - 1 > 0 ? zoom - 1 : zoom; - let zoomStop = zoom + 1 < 20 ? zoom + 1 : zoom; - let styles = leafletObject.wmsParams.styles; - let parameterStyles = ''; - if (!Ember.isNone(styles)) { - parameterStyles = `parameter_STYLES=${workspace}:${styles}&`; - } - - let crsName = leafletObject.wmsParams.crs; - let crs; - if (!Ember.isNone(crsName)) { - crs = getLeafletCrs('{ "code": "' + crsName.toUpperCase() + '", "definition": "" }', this); - } - - let bounds = leafletMap.getBounds(); - let minXY = L.marker(bounds._southWest).toProjectedGeoJSON(crs); - let maxXY = L.marker(bounds._northEast).toProjectedGeoJSON(crs); - - Ember.$.ajax({ - method: 'POST', - url: url, - async: true, - data: `threadCount=01&type=truncate&gridSetId=${gridSetId}&tileFormat=image%2Fpng&zoomStart=${zoomStart}&zoomStop=${zoomStop}&` + - `${parameterStyles}minX=${minXY.geometry.coordinates[0]}&minY=${minXY.geometry.coordinates[1]}` + - `&maxX=${maxXY.geometry.coordinates[0]}&maxY=${maxXY.geometry.coordinates[1]}`, - contentType: 'text/html', - error: function(data) { - console.error(data); - } - }); - } - }, - actions: { blockForm(block) { @@ -1248,8 +1172,9 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, this.set('mode', 'Saved'); let _leafletObjectFirst = this.get('layerModel.layerModel._leafletObjectFirst'); + let leafletMap = this.get('leafletMap'); if (!Ember.isNone(_leafletObjectFirst) && typeof _leafletObjectFirst.setParams === 'function') { - this.trancateGeoWebCache(_leafletObjectFirst); + this.trancateGeoWebCache(_leafletObjectFirst, leafletMap); _leafletObjectFirst.setParams({ fake: Date.now() }, false); } diff --git a/addon/components/flexberry-layers-attributes-panel.js b/addon/components/flexberry-layers-attributes-panel.js index 600e11b31..36f69eb93 100644 --- a/addon/components/flexberry-layers-attributes-panel.js +++ b/addon/components/flexberry-layers-attributes-panel.js @@ -948,6 +948,12 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, this.set('loading', false); tabModel._reload(); leafletObject.off('save:failed', saveFailed); + + let _leafletObjectFirst = tabModel.layerModel._leafletObjectFirst; + if (!Ember.isNone(_leafletObjectFirst) && typeof _leafletObjectFirst.setParams === 'function') { + this.trancateGeoWebCache(_leafletObjectFirst, leafletMap); + _leafletObjectFirst.setParams({ fake: Date.now() }, false); + } }; this.set('loading', true); diff --git a/addon/mixins/edit-feature.js b/addon/mixins/edit-feature.js index 75836b72c..ac54c8343 100644 --- a/addon/mixins/edit-feature.js +++ b/addon/mixins/edit-feature.js @@ -1,5 +1,6 @@ import Ember from 'ember'; +import { getLeafletCrs } from '../utils/leaflet-crs'; export default Ember.Mixin.create({ @@ -54,5 +55,80 @@ export default Ember.Mixin.create({ return L.geoJson(layer.toGeoJSON(), { pane: 'zoomto' }).setStyle(this.get('zoomFeatureStyle')); + }, + + /** + Sends request to trancate GeoWebCache for layer by boundingBox. + + @method trancateGeoWebCache + @param {Object} leafletObject laeflet layer. + @param {Object} leafletMap laeflet map. + */ + trancateGeoWebCache(leafletObject, leafletMap) { + let layers = leafletObject.wmsParams.layers.split(); + let workspace; + let layer; + let geoWebCache; + if (layers.length === 2) { + workspace = layers[0]; + layer = layers[1]; + } else { + let urlSplit = leafletObject._url.split('/'); + let indexGeoserver = urlSplit.indexOf('geoserver'); + if (indexGeoserver > -1 && urlSplit.length === indexGeoserver + 3) { + workspace = urlSplit.at(indexGeoserver + 1); + } else { + console.error('Can\'t get workspace in geoserver'); + return; + } + + layer = layers[0]; + } + + if (!Ember.isBlank(leafletObject._url.match(new RegExp('(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?')))) { + let indexGeoserver = leafletObject._url.indexOf('geoserver'); + if (indexGeoserver === -1) { + console.error('Can\'t get url geoserver'); + return; + } + + geoWebCache = leafletObject._url.slice(0, indexGeoserver + 10) + '/gwc/rest/seed/'; + } + + if (!Ember.isNone(geoWebCache)) { + let url = geoWebCache + workspace + ':' + layer; + let gridSetId = leafletObject.wmsParams.crs + '_' + leafletObject.wmsParams.width; + let zoom = Math.trunc(leafletMap.getZoom()); + let zoomStart = zoom - 1 > 0 ? zoom - 1 : zoom; + let zoomStop = zoom + 1 < 20 ? zoom + 1 : zoom; + let styles = leafletObject.wmsParams.styles; + let parameterStyles = ''; + if (!Ember.isNone(styles)) { + parameterStyles = `parameter_STYLES=${workspace}:${styles}&`; + } + + let crsName = leafletObject.wmsParams.crs; + let crs; + if (!Ember.isNone(crsName)) { + crs = getLeafletCrs('{ "code": "' + crsName.toUpperCase() + '", "definition": "" }', this); + } + + let bounds = leafletMap.getBounds(); + let minXY = L.marker(bounds._southWest).toProjectedGeoJSON(crs); + let maxXY = L.marker(bounds._northEast).toProjectedGeoJSON(crs); + + Ember.$.ajax({ + method: 'POST', + url: url, + async: true, + data: `threadCount=01&type=truncate&gridSetId=${gridSetId}&tileFormat=image%2Fpng&zoomStart=${zoomStart}&zoomStop=${zoomStop}&` + + `${parameterStyles}minX=${minXY.geometry.coordinates[0]}&minY=${minXY.geometry.coordinates[1]}` + + `&maxX=${maxXY.geometry.coordinates[0]}&maxY=${maxXY.geometry.coordinates[1]}`, + contentType: 'text/html', + error: function (data) { + console.error(data); + } + }); + } } }); diff --git a/addon/mixins/flexberry-maplayer-actions-handler.js b/addon/mixins/flexberry-maplayer-actions-handler.js index 9064a1ee6..55dc70edc 100644 --- a/addon/mixins/flexberry-maplayer-actions-handler.js +++ b/addon/mixins/flexberry-maplayer-actions-handler.js @@ -404,7 +404,7 @@ export default Ember.Mixin.create({ let rootArray = this.get(rootPath); rootArray.pushObject(childLayer); - setIndexes(rootArray, this.get('model.hierarchy')); + setIndexes(rootArray, this.get('model.otherLayers')); }, /** @@ -539,7 +539,7 @@ export default Ember.Mixin.create({ let rootArray = this.get(rootPath); - setIndexes(rootArray, this.get('model.hierarchy')); + setIndexes(rootArray, this.get('model.otherLayers')); } }, From df70bf3336f2e57cee1e6a7569e1f429917d1a91 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 23 Oct 2023 14:40:36 +0500 Subject: [PATCH 07/33] marker anchor --- addon/markers-styles/default.js | 4 +- addon/markers-styles/image.js | 21 +++-- addon/mixins/layer-label.js | 12 +-- addon/services/markers-styles-renderer.js | 98 ++++++++++++++++++++++- 4 files changed, 118 insertions(+), 17 deletions(-) diff --git a/addon/markers-styles/default.js b/addon/markers-styles/default.js index 8e58ff509..dc7b7a833 100644 --- a/addon/markers-styles/default.js +++ b/addon/markers-styles/default.js @@ -54,11 +54,11 @@ export default BaseMarkerStyle.extend({ @param {Object} options.style Hash containing style settings. @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). */ - renderOnCanvas({ canvas, style, target }) { + renderOnCanvas({ canvas, style, target, scale }) { // Default 'image' markers-style's settings are settings for leaflet default image icon (L.Icon.Default), // so we can reuse 'image' markers-style here. let markersStylesRenderer = this.get('_markersStylesRenderer'); let defaultMarkerStyleSettings = markersStylesRenderer.getDefaultStyleSettings('image'); - markersStylesRenderer.renderOnCanvas({ canvas, styleSettings: defaultMarkerStyleSettings, target }); + markersStylesRenderer.renderOnCanvas({ canvas, styleSettings: defaultMarkerStyleSettings, target, scale }); } }); diff --git a/addon/markers-styles/image.js b/addon/markers-styles/image.js index 0484cd383..50407f562 100644 --- a/addon/markers-styles/image.js +++ b/addon/markers-styles/image.js @@ -63,7 +63,7 @@ export default BaseMarkerStyle.extend({ @param {Object} options.style Hash containing style settings. @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). */ - renderOnCanvas({ canvas, style, target }) { + renderOnCanvas({ canvas, style, target, scale }) { let width = canvas.width; let height = canvas.height; let ctx = canvas.getContext('2d'); @@ -76,12 +76,19 @@ export default BaseMarkerStyle.extend({ // Draw loaded image. let iconWidth = style.iconSize[0] || iconImage.width; let iconHeight = style.iconSize[1] || iconImage.height; - - let scale = iconWidth > width || iconHeight > height ? - Math.min(width / iconWidth, height / iconHeight) : - 1; - let xOffset = (width - iconWidth * scale) / 2; - let yOffset = (height - iconHeight * scale) / 2; + let xOffset = 0; + let yOffset = 0; + + if (Ember.isNone(scale)) { + scale = iconWidth > width || iconHeight > height ? + Math.min(width / iconWidth, height / iconHeight) : + 1; + xOffset = (width - iconWidth * scale) / 2; + yOffset = (height - iconHeight * scale) / 2; + } else { + xOffset = width/2 - style.iconAnchor[0] * scale; + yOffset = height/2 - style.iconAnchor[1] * scale; + } let drawIconImage = function() { ctx.drawImage(iconImage, xOffset, yOffset, iconWidth * scale, iconHeight * scale); diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 799ef04fc..b17fd4e40 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -1185,8 +1185,6 @@ export default Ember.Mixin.create({ } Ember.$('path#' + id).attr('d', d); - Ember.$('svg#svg-' + id).attr('width', svg.getAttribute('width')); - Ember.$('svg#svg-' + id).attr('height', svg.getAttribute('height')); let options = layer._textOptions; let text = layer._text; @@ -1199,8 +1197,8 @@ export default Ember.Mixin.create({ let bbox = document.getElementById(id).getBBox(); layer._svg.setAttribute('height', bbox.height + buffer); layer._svg.setAttribute('width', bbox.width + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('height', bbox.height + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('width', bbox.width + buffer); + Ember.$('svg#svg-' + id).attr('height', bbox.height + buffer); + Ember.$('svg#svg-' + id).attr('width', bbox.width + buffer); }, _createLabelsLayerOldSettings(labelsLayersArray) { @@ -1356,7 +1354,11 @@ export default Ember.Mixin.create({ labelsLayers.forEach(labelLayer => { leafletContainer.addLayer(labelLayer); labelLayer.eachLayer(layer => { - this._setOptionsForSvg(layer); + if (layer instanceof L.FeatureGroup) { + layer.eachLayer(partLayer => { this._setOptionsForSvg(partLayer); }); + } else { + this._setOptionsForSvg(layer); + } }); }); } diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index e8bad4f1d..291c9726e 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -95,6 +95,22 @@ export default Ember.Service.extend({ }; }, + /** + Gets style for default marker. + + @method getDefaultMarkerSettings + @return {Object} Hash containing default style settings (for example { iconUrl: ..., shadowUrl: ..., ... }). + */ + getDefaultMarkerSettings() { + let markerStyle = this._getMarkerStyle('image'); + if (Ember.isNone(markerStyle)) { + Ember.Logger.error(`Service 'markers-styles-renderer' can't get default style settings for '${type}' markers-style.`); + return null; + } + + return markerStyle.getDefaultStyleSettings(); + }, + /** Applies marker-style to the specified leaflet marker. @@ -126,10 +142,14 @@ export default Ember.Service.extend({ @param {Object} options.styleSettings Hash containing style settings. @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). */ - renderOnCanvas({ canvas, styleSettings, target }) { + renderOnCanvas({ canvas, styleSettings, target, scale }) { target = target || 'preview'; if (Ember.isArray(styleSettings)) { + if (!scale && styleSettings.length > 1) { + scale = this.calcScale(styleSettings); + } + styleSettings.forEach(settings => { let type = Ember.get(settings, 'type'); let style = Ember.get(settings, 'style'); @@ -140,7 +160,7 @@ export default Ember.Service.extend({ return; } - markerStyle.renderOnCanvas({ canvas, style, target }); + markerStyle.renderOnCanvas({ canvas, style, target, scale }); }); } else { let type = Ember.get(styleSettings, 'type'); @@ -152,8 +172,80 @@ export default Ember.Service.extend({ return; } - markerStyle.renderOnCanvas({ canvas, style, target }); + markerStyle.renderOnCanvas({ canvas, style, target, scale }); + } + }, + + /** + Size canvas for legend. + + @property size + @type Number + @default 24 + @private + */ + _size: 24, + + /** + Calculate scale for canvas of legend. + + @method calcScale + @param {Object} styleSettings style settings. + @return {Object} Hash containing style settings. + */ + calcScale(styleSettings) { + let maxSize = this.get('_size'); + let max = 0; + let top = 0, bottom = 0, left = 0, right = 0; + if (!Ember.isArray(styleSettings)) { + let style = styleSettings.style; + if (styleSettings.type === 'default') { + style = this.getDefaultMarkerSettings(); + } + + let iconWidth = style.iconSize[0]; + let iconHeight = style.iconSize[1]; + return iconWidth > maxSize || iconHeight > maxSize ? + Math.min(maxSize / iconWidth, maxSize / iconHeight) : + 1; + } + + if (styleSettings.length === 1) { + let iconSize; + if (styleSettings.get('firstObject.type') === 'default') { + iconSize = this.getDefaultMarkerSettings().iconSize; + } else { + iconSize = styleSettings.get('firstObject.style.iconSize') + } + + max = Math.max(iconSize[0], iconSize[1]); + } else { + styleSettings.forEach((settings) => { + let style = settings.style; + if (settings.type === 'default') { + style = this.getDefaultMarkerSettings(); + } + + if (!Ember.isNone(style)) { + let width = style.iconSize[0]; + let height = style.iconSize[1]; + let anchorH = style.iconAnchor[1]; + let anchorW = style.iconAnchor[0]; + + if ((0 - anchorH) < top) { top = (0 - anchorH); } + if ((height - anchorH) > bottom) { bottom = (height - anchorH); } + if ((0 - anchorW) < left) { left = (0 - anchorW); } + if ((width - anchorW) > right) { right = (width - anchorW); } + } + }); + + max = (Math.max(Math.abs(top), Math.abs(bottom), Math.abs(left), Math.abs(right))) * 2; + } + + if (max <= maxSize) { + return 1; } + return maxSize / max; } }); From 9ebc0bebf441dae75478015a14b476599911c605 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 23 Oct 2023 15:42:43 +0500 Subject: [PATCH 08/33] fix opacity --- addon/initializers/leaflet-path.js | 23 ++++++++++++++++++++++- addon/layers-styles/simple.js | 6 +++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/addon/initializers/leaflet-path.js b/addon/initializers/leaflet-path.js index 4aa8f5ca7..dfdc1589c 100644 --- a/addon/initializers/leaflet-path.js +++ b/addon/initializers/leaflet-path.js @@ -6,7 +6,15 @@ import Ember from 'ember'; export function initialize() { let setStyle = { setStyle: function (style) { - L.Path.prototype.setStyle.call(this, style); + if (this.options.count) { + for (let i = 0; i < this.options.count; i++) { + if (!style.count) { + this.setStyleCustom(this, this.options[i], style); + } + } + } else { + L.Path.prototype.setStyle.call(this, style); + } if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { this.layerModel.legendStyle = { type: 'simple', @@ -17,6 +25,19 @@ export function initialize() { } return this; + }, + + setStyleCustom(layer, options, style) { + for (var j in style) { + options[j] = style[j]; + } + + if (layer._renderer) { + layer._renderer._updateStyle(layer); + if (options.stroke && style && style.hasOwnProperty('weight')) { + layer._updateBounds(); + } + } } }; diff --git a/addon/layers-styles/simple.js b/addon/layers-styles/simple.js index 26c0bc9c6..45062eca2 100644 --- a/addon/layers-styles/simple.js +++ b/addon/layers-styles/simple.js @@ -57,10 +57,10 @@ export default BaseLayerStyle.extend({ if (Ember.isNone(path.styleIsSet) || !path.styleIsSet) { let pathStyle = style.path || {}; if (Ember.isArray(pathStyle)) { - pathStyle.forEach(style => { - style = Ember.$.extend(true, {}, style, { + pathStyle.forEach(styleInner => { + styleInner = Ember.$.extend(true, {}, styleInner, { // Fill must be disabled for non polygon layers, because filled polylines and other lines-like geometries looks ugly in leaflet. - fill: style.fill === true && path instanceof L.Polygon + fill: styleInner.fill === true && path instanceof L.Polygon }); }); pathStyle.count = pathStyle.length; From 2c601bd4d56d847d96b97c5795b85c7d56816b1e Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 24 Oct 2023 11:23:40 +0500 Subject: [PATCH 09/33] fix style for rule --- addon/initializers/leaflet-path.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addon/initializers/leaflet-path.js b/addon/initializers/leaflet-path.js index dfdc1589c..30ccd35bf 100644 --- a/addon/initializers/leaflet-path.js +++ b/addon/initializers/leaflet-path.js @@ -10,11 +10,14 @@ export function initialize() { for (let i = 0; i < this.options.count; i++) { if (!style.count) { this.setStyleCustom(this, this.options[i], style); + } else { + L.Path.prototype.setStyle.call(this, style); } } } else { L.Path.prototype.setStyle.call(this, style); } + if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { this.layerModel.legendStyle = { type: 'simple', From a1c9c9558b535ae579d95a58632ed999a0756f5f Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 24 Oct 2023 15:18:32 +0500 Subject: [PATCH 10/33] fix null leafletObject --- addon/mixins/layer-label.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 799ef04fc..ee91f5531 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -244,27 +244,29 @@ export default Ember.Mixin.create({ _labelValue(layer, property, prop, str) { let leafletObject = this.returnLeafletObject(); - let readFormat = Ember.get(leafletObject, 'readFormat.featureType.fieldTypes'); - let label = layer.feature.properties[property]; - let dateTimeFormat = this.displaySettings.dateTimeFormat; - let dateFormat = this.displaySettings.dateFormat; - if (readFormat[property] === 'date' && (!Ember.isEmpty(dateFormat) || !Ember.isEmpty(dateTimeFormat))) { - let dateValue = moment(label); - - if (dateValue.isValid()) { - if (!Ember.isEmpty(dateTimeFormat)) { - label = (dateValue.format('HH:mm:ss') === '00:00:00') ? dateValue.format(dateFormat) : dateValue.format(dateTimeFormat); - } else { - label = dateValue.format(dateFormat); + if (!Ember.isNone(leafletObject)) { + let readFormat = Ember.get(leafletObject, 'readFormat.featureType.fieldTypes'); + let label = layer.feature.properties[property]; + let dateTimeFormat = this.displaySettings.dateTimeFormat; + let dateFormat = this.displaySettings.dateFormat; + if (readFormat[property] === 'date' && (!Ember.isEmpty(dateFormat) || !Ember.isEmpty(dateTimeFormat))) { + let dateValue = moment(label); + + if (dateValue.isValid()) { + if (!Ember.isEmpty(dateTimeFormat)) { + label = (dateValue.format('HH:mm:ss') === '00:00:00') ? dateValue.format(dateFormat) : dateValue.format(dateTimeFormat); + } else { + label = dateValue.format(dateFormat); + } } } - } - if (Ember.isNone(label)) { - label = ''; - } + if (Ember.isNone(label)) { + label = ''; + } - str = str.replace(prop.outerHTML, label); + str = str.replace(prop.outerHTML, label); + } return str; }, From a044156fc668bb53cba598cf81a7d28463ed10cb Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 24 Oct 2023 15:38:06 +0500 Subject: [PATCH 11/33] fix empty leafletObject --- addon/mixins/layer-label.js | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index ee91f5531..96cb3225a 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -206,7 +206,7 @@ export default Ember.Mixin.create({ @param {Object} layer layer @return {String} string with replaced property */ - _applyProperty(str, layer) { + _applyProperty(str, layer, leafletObject) { let hasReplace = false; let propName; @@ -230,7 +230,7 @@ export default Ember.Mixin.create({ } if (property && layer.feature.properties && layer.feature.properties.hasOwnProperty(property)) { - str = this._labelValue(layer, property, prop, str); + str = this._labelValue(layer, property, prop, str, leafletObject); } } } @@ -242,32 +242,33 @@ export default Ember.Mixin.create({ } }, - _labelValue(layer, property, prop, str) { - let leafletObject = this.returnLeafletObject(); - if (!Ember.isNone(leafletObject)) { - let readFormat = Ember.get(leafletObject, 'readFormat.featureType.fieldTypes'); - let label = layer.feature.properties[property]; - let dateTimeFormat = this.displaySettings.dateTimeFormat; - let dateFormat = this.displaySettings.dateFormat; - if (readFormat[property] === 'date' && (!Ember.isEmpty(dateFormat) || !Ember.isEmpty(dateTimeFormat))) { - let dateValue = moment(label); - - if (dateValue.isValid()) { - if (!Ember.isEmpty(dateTimeFormat)) { - label = (dateValue.format('HH:mm:ss') === '00:00:00') ? dateValue.format(dateFormat) : dateValue.format(dateTimeFormat); - } else { - label = dateValue.format(dateFormat); - } - } - } + _labelValue(layer, property, prop, str, leafletObject) { + if (Ember.isNone(leafletObject)) { + leafletObject = this.returnLeafletObject(); + } + + let readFormat = Ember.get(leafletObject, 'readFormat.featureType.fieldTypes'); + let label = layer.feature.properties[property]; + let dateTimeFormat = this.displaySettings.dateTimeFormat; + let dateFormat = this.displaySettings.dateFormat; + if (readFormat[property] === 'date' && (!Ember.isEmpty(dateFormat) || !Ember.isEmpty(dateTimeFormat))) { + let dateValue = moment(label); - if (Ember.isNone(label)) { - label = ''; + if (dateValue.isValid()) { + if (!Ember.isEmpty(dateTimeFormat)) { + label = (dateValue.format('HH:mm:ss') === '00:00:00') ? dateValue.format(dateFormat) : dateValue.format(dateTimeFormat); + } else { + label = dateValue.format(dateFormat); + } } + } - str = str.replace(prop.outerHTML, label); + if (Ember.isNone(label)) { + label = ''; } + str = str.replace(prop.outerHTML, label); + return str; }, @@ -331,9 +332,8 @@ export default Ember.Mixin.create({ @method _showLabelsMovingMap */ _showLabelsMovingMap() { - let labelsLayers = this.get('labelsLayers'); let leafletObject = this.returnLeafletObject(); - this._createStringLabel(leafletObject.getLayers(), labelsLayers); + this._createStringLabel(leafletObject.getLayers(), leafletObject); }, /** @@ -342,7 +342,7 @@ export default Ember.Mixin.create({ @method _createStringLabel @param {Array} layers new layers for add labels */ - _createStringLabel(layers) { + _createStringLabel(layers, leafletObject) { if (layers) { let labelsLayerZoom = this._getLabelsLayersZoom(); if (labelsLayerZoom) { @@ -360,7 +360,7 @@ export default Ember.Mixin.create({ `text-align: ${Ember.get(optionsLabel, 'captionFontAlign')};${halo}`); this._checkLabelInView(layers, labelsLayerZoom).forEach(layer => { - let label = layer.labelValue || this._applyFunction(this._applyProperty(labelSettingsString, layer)); + let label = layer.labelValue || this._applyFunction(this._applyProperty(labelSettingsString, layer, leafletObject)); this._createLabel(label, layer, style, labelsLayerZoom); }); } @@ -1317,7 +1317,7 @@ export default Ember.Mixin.create({ this._labelsLayersCreate(leafletObject); labelsLayers = this.get('labelsLayers'); - this._createStringLabel(layers, labelsLayers); + this._createStringLabel(layers, leafletObject); if (Ember.isNone(this.get('labelsLayers'))) { this.set('labelsLayers', labelsLayers); this._checkZoomPane(); From 957c981586bb667f75d4ac0f017545403f89b5bf Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Wed, 25 Oct 2023 15:05:12 +0500 Subject: [PATCH 12/33] fix update line --- addon/mixins/layer-label.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 96cb3225a..50a09b432 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -1190,19 +1190,24 @@ export default Ember.Mixin.create({ Ember.$('svg#svg-' + id).attr('width', svg.getAttribute('width')); Ember.$('svg#svg-' + id).attr('height', svg.getAttribute('height')); - let options = layer._textOptions; let text = layer._text; let textNode = layer._textNode; - this._setAlignForLine(layer, text, options.align, textNode, settingsLabel); + this._setAlignForLine(layer, text, settingsLabel.options.captionFontAlign, textNode, settingsLabel); Ember.$('text#text-' + id).attr('dx', textNode.getAttribute('dx')); let buffer = 150; - let bbox = document.getElementById(id).getBBox(); - layer._svg.setAttribute('height', bbox.height + buffer); - layer._svg.setAttribute('width', bbox.width + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('height', bbox.height + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('width', bbox.width + buffer); + let pathElement = document.getElementById(id); + if (pathElement) { + let bbox = pathElement.getBBox(); + layer._svg.setAttribute('height', bbox.height + buffer); + layer._svg.setAttribute('width', bbox.width + buffer); + let svgElement = document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')); + if (svgElement) { + svgElement.setAttribute('height', bbox.height + buffer); + svgElement.setAttribute('width', bbox.width + buffer); + } + } }, _createLabelsLayerOldSettings(labelsLayersArray) { From f0d353607eb95ceefcf3c9333aa77aa74fb92503 Mon Sep 17 00:00:00 2001 From: Pepelyaeva Kseniya Date: Wed, 25 Oct 2023 17:18:43 +0500 Subject: [PATCH 13/33] Fix zoom-view button style --- addon/styles/themes/default/elements/container.overrides | 1 - 1 file changed, 1 deletion(-) diff --git a/addon/styles/themes/default/elements/container.overrides b/addon/styles/themes/default/elements/container.overrides index b290ce050..2c1173cfa 100644 --- a/addon/styles/themes/default/elements/container.overrides +++ b/addon/styles/themes/default/elements/container.overrides @@ -122,7 +122,6 @@ line-height: 14px; font-weight: 700; &:hover { - border: none; background: @buttonMenuHoveredBackground; } } From cbb9027b3aeadf99847a598b0cdcfa11fb23f510 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Thu, 26 Oct 2023 10:11:00 +0500 Subject: [PATCH 14/33] remove empty geometry --- addon/mixins/flexberry-check-file.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addon/mixins/flexberry-check-file.js b/addon/mixins/flexberry-check-file.js index 22b260831..b7e4a9792 100644 --- a/addon/mixins/flexberry-check-file.js +++ b/addon/mixins/flexberry-check-file.js @@ -49,6 +49,10 @@ export default Ember.Mixin.create({ let layer = null; try { + let features = response.features.filter((feature) => { + return !Ember.isNone(feature.geometry) && feature.geometry.coordinates.flat(5).length > 0; + }); + response.features = features; layer = this._createLayer(response, crs); } catch (ex) { From 9252b3c49e7895a5900fc0cff326272d5a513e10 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 30 Oct 2023 17:50:24 +0500 Subject: [PATCH 15/33] fix label for marker --- addon/markers-styles/image.js | 26 +++++---- addon/mixins/layer-label.js | 106 +++++++++++++++++++++++++++------- 2 files changed, 101 insertions(+), 31 deletions(-) diff --git a/addon/markers-styles/image.js b/addon/markers-styles/image.js index 50407f562..07631d1fb 100644 --- a/addon/markers-styles/image.js +++ b/addon/markers-styles/image.js @@ -54,6 +54,18 @@ export default BaseMarkerStyle.extend({ } }, + getAnchor(style) { + let aW = 0.5; + let aH = 0.5; + + if (!Ember.isNone(style)) { + aW = style.iconAnchor[0]; + aH = style.iconAnchor[1]; + } + + return [Math.round(Number(style.iconSize[0]) * aW), Math.round(Number(style.iconSize[1]) * aH)]; + }, + /** Renderes marker-style preview on the specified canvas element. @@ -72,6 +84,7 @@ export default BaseMarkerStyle.extend({ ctx.clearRect(0, 0, width, height); var iconImage = new Image(); + let _this = this; iconImage.onload = function() { // Draw loaded image. let iconWidth = style.iconSize[0] || iconImage.width; @@ -79,16 +92,9 @@ export default BaseMarkerStyle.extend({ let xOffset = 0; let yOffset = 0; - if (Ember.isNone(scale)) { - scale = iconWidth > width || iconHeight > height ? - Math.min(width / iconWidth, height / iconHeight) : - 1; - xOffset = (width - iconWidth * scale) / 2; - yOffset = (height - iconHeight * scale) / 2; - } else { - xOffset = width/2 - style.iconAnchor[0] * scale; - yOffset = height/2 - style.iconAnchor[1] * scale; - } + let anchor = _this.getAnchor(style); + xOffset = width/2 - anchor[0] * scale; + yOffset = height/2 - anchor[1] * scale; let drawIconImage = function() { ctx.drawImage(iconImage, xOffset, yOffset, iconWidth * scale, iconHeight * scale); diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index b17fd4e40..2c582b49f 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -426,7 +426,7 @@ export default Ember.Mixin.create({ let className = 'label'; className += ' point ' + positionPoint.cssClass; let html = '
' + text + '
'; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, positionPoint.iconSize, anchor); let label = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); this._addLabel(label, labelsLayerZoom, layer); }, @@ -594,13 +594,12 @@ export default Ember.Mixin.create({ this._addLabel(label, labelsLayerZoom, layer); }, - _optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor) { + _optionsMarker(latlng, className, html, iconSize, anchor) { return { latlng, className, html, - iconWidth, - iconHeight, + iconSize, anchor }; }, @@ -628,7 +627,7 @@ export default Ember.Mixin.create({ let paramsDivIcon = { className: options.className, html: options.html, - iconSize: [options.iconWidth, options.iconHeight], + iconSize: options.iconSize, iconAnchor: options.anchor }; let icon = L.divIcon(paramsDivIcon); @@ -679,27 +678,31 @@ export default Ember.Mixin.create({ return minPosition; }, - _defaultMarkerOptions() { + _defaultMarkerOptions(locationPoint) { return { iconSize: [25, 41], - iconAnchor: [12, 41] + iconAnchor: locationPoint.indexOf('over') >= 0 ? [12, 41] : [12, 20] }; }, - _positionForComboStyle(stylesMarker) { + _positionForComboStyle(stylesMarker, locationPoint) { let leftMin = 0; let rightMax = 0; let topMin = 0; let bottomMax = 0; + let widthMax = 0; + let heightMax = 0; let left = 0; let right = 0; let top = 0; let bottom = 0; + let width = 0; + let height = 0; stylesMarker.forEach(styleMarker => { let style = styleMarker.style; if (styleMarker.type === 'default') { - style = this._defaultMarkerOptions; + style = this._defaultMarkerOptions(locationPoint); } if (!Ember.isNone(style)) { @@ -710,10 +713,14 @@ export default Ember.Mixin.create({ right = (iconSize[0] || 0) - (iconAnchor[0] || 0); top = iconAnchor[1] || 0; bottom = (iconSize[1] || 0) - (iconAnchor[1] || 0); + width = iconSize[0]; + height = iconSize[1]; leftMin = this._positionMin(leftMin, left); rightMax = this._positionMax(rightMax, right); topMin = this._positionMin(topMin, top); bottomMax = this._positionMax(bottomMax, bottom); + widthMax = this._positionMax(widthMax, width); + heightMax = this._positionMax(heightMax, height); } } }); @@ -722,7 +729,9 @@ export default Ember.Mixin.create({ left: leftMin, right: rightMax, top: topMin, - bottom: bottomMax + bottom: bottomMax, + width: widthMax, + height: heightMax }; }, @@ -738,24 +747,32 @@ export default Ember.Mixin.create({ // значения для маркера по умолчанию let left = 12.5; let right = 12.5; - let top = 41; + let top = 20.5; let bottom = 0; let stylesMarker = this.get('styleSettings.style.marker'); if (stylesMarker && Ember.isArray(stylesMarker) && stylesMarker.length > 0) { - let options = this._positionForComboStyle(stylesMarker); + let options = this._positionForComboStyle(stylesMarker, settingsLabel.location.locationPoint); left = options.left; right = options.right; top = options.top; bottom = options.bottom; + width = options.width; + height = options.height; } else { - let iconSize = this.get('styleSettings.style.marker.style.iconSize'); - let iconAnchor = this.get('styleSettings.style.marker.style.iconAnchor'); + let style = styleMarker.style; + if (styleMarker.type === 'default') { + style = this._defaultMarkerOptions(settingsLabel.location.locationPoint); + } + let iconSize = style.iconSize; + let iconAnchor = style.iconAnchor; if (!Ember.isNone(iconAnchor) && iconAnchor.length === 2 && !Ember.isNone(iconSize) && iconSize.length === 2) { left = iconAnchor[0] || 0; right = (iconSize[0] || 0) - (iconAnchor[0] || 0); top = iconAnchor[1] || 0; bottom = (iconSize[1] || 0) - (iconAnchor[1] || 0); + width = iconSize[0] || 0; + height = iconSize[1] || 0; } } @@ -766,12 +783,12 @@ export default Ember.Mixin.create({ switch (settingsLabel.location.locationPoint) { case 'overLeft': style = 'text-align: right;'; - anchor = [left + width, top + height]; + anchor = [left + width - 2, top + height - 2]; cssClass = 'over left'; break; case 'overRight': style = 'text-align: left;'; - anchor = [-1 * right, top + height]; + anchor = [-1 * right + 2, top + height - 2]; cssClass = 'over right'; break; case 'alongLeft': @@ -791,27 +808,29 @@ export default Ember.Mixin.create({ break; case 'underLeft': style = 'text-align: right;'; - anchor = [left + width, -1 * bottom]; + anchor = [left + width, -1 * bottom + 2]; cssClass = 'under left'; break; case 'underMiddle': style = 'text-align: center;'; - anchor = [Math.round((width - (right - left)) / 2), -1 * bottom]; + anchor = [Math.round((width - (right - left)) / 2), -1 * bottom + 2]; cssClass = 'under middle'; break; case 'underRight': style = 'text-align: left;'; - anchor = [-1 * right, -1 * bottom]; + anchor = [-1 * right, -1 * bottom + 2]; cssClass = 'under right'; break; default: // and overMiddle style = 'text-align: center;'; - anchor = [Math.round((width - (right - left)) / 2), top + height]; + anchor = [Math.round((width - (right - left)) / 2), top + height - 2]; cssClass = 'over middle'; break; } - return { style, anchor, cssClass }; + let iconSize = [width, height]; + + return { style, anchor, cssClass, iconSize }; }, /** @@ -1171,6 +1190,45 @@ export default Ember.Mixin.create({ } }, + /** + Update position for marker object's label + + @method _updatePositionLabelForLine + */ + _updatePositionLabelForMarker() { + let leafletObject = this.returnLeafletObject(); + let _this = this; + let labelsLayersZoom = this._getLabelsLayersZoom(); + + if (!Ember.isNone(leafletObject) && labelsLayersZoom && this.get('leafletMap').hasLayer(labelsLayersZoom)) { + // обновлять будем только то что видно + this._checkLabelInView(leafletObject.getLayers(), labelsLayersZoom, false).forEach(layer => { + if (!Ember.isNone(layer._icon) && !Ember.isNone(layer._label)) { + layer._label.forEach(zoomLabel => { + if (zoomLabel instanceof L.FeatureGroup) { + zoomLabel.getLayers().forEach((label) => { + _this._updateAttributesMarker(label, labelsLayersZoom.settings); + }); + } else { + _this._updateAttributesMarker(zoomLabel, labelsLayersZoom.settings); + } + }); + } + }); + } + }, + + _updateAttributesMarker(label, settings) { + let options = this._setPositionPoint(label.options.icon.options.iconSize[0], + label.options.icon.options.iconSize[1], settings); + + let icon = label.getIcon(); + icon.options.iconAnchor = options.anchor; + icon.options.iconSize = options.iconSize; + icon.options.className = 'label point ' + options.cssClass; + label.setIcon(icon); + }, + _updateAttributesSvg(layer, partline, svg, path, settingsLabel) { this._setLabelLine(layer, svg, partline, layer._text, settingsLabel); let d = layer._path.getAttribute('d'); @@ -1276,6 +1334,8 @@ export default Ember.Mixin.create({ if (this.get('typeGeometry') === 'polyline') { leafletMap.on('zoomend', this._updatePositionLabelForLine, this); + } else if (this.get('typeGeometry') === 'marker') { + leafletMap.on('zoomend', this._updatePositionLabelForMarker, this); } // для showExisting не грузим все надписи сразу. слишком много. поэтому приходится догружать при сдвиге карты, как будто это continueLoading, @@ -1321,6 +1381,8 @@ export default Ember.Mixin.create({ if (this.get('typeGeometry') === 'polyline') { this._updatePositionLabelForLine(); + } else if (this.get('typeGeometry') === 'marker') { + this._updatePositionLabelForMarker(); } } }, @@ -1446,6 +1508,8 @@ export default Ember.Mixin.create({ this._checkZoomPane(); if (this.get('typeGeometry') === 'polyline') { this._updatePositionLabelForLine(); + } else if (this.get('typeGeometry') === 'marker') { + this._updatePositionLabelForMarker(); } } }, From abe2490c5772f15731f67c56cd61c75eb3e03bd6 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Mon, 30 Oct 2023 18:07:26 +0500 Subject: [PATCH 16/33] fix jscs test --- addon/markers-styles/image.js | 4 ++-- addon/mixins/layer-label.js | 5 +++-- addon/services/markers-styles-renderer.js | 12 +++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/addon/markers-styles/image.js b/addon/markers-styles/image.js index 07631d1fb..99e514616 100644 --- a/addon/markers-styles/image.js +++ b/addon/markers-styles/image.js @@ -93,8 +93,8 @@ export default BaseMarkerStyle.extend({ let yOffset = 0; let anchor = _this.getAnchor(style); - xOffset = width/2 - anchor[0] * scale; - yOffset = height/2 - anchor[1] * scale; + xOffset = width / 2 - anchor[0] * scale; + yOffset = height / 2 - anchor[1] * scale; let drawIconImage = function() { ctx.drawImage(iconImage, xOffset, yOffset, iconWidth * scale, iconHeight * scale); diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 1ec59caf5..9ade923ad 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -762,10 +762,11 @@ export default Ember.Mixin.create({ width = options.width; height = options.height; } else { - let style = styleMarker.style; - if (styleMarker.type === 'default') { + let style = stylesMarker.style; + if (stylesMarker.type === 'default') { style = this._defaultMarkerOptions(settingsLabel.location.locationPoint); } + let iconSize = style.iconSize; let iconAnchor = style.iconAnchor; if (!Ember.isNone(iconAnchor) && iconAnchor.length === 2 && !Ember.isNone(iconSize) && iconSize.length === 2) { diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index 291c9726e..9fd8400f2 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -104,7 +104,7 @@ export default Ember.Service.extend({ getDefaultMarkerSettings() { let markerStyle = this._getMarkerStyle('image'); if (Ember.isNone(markerStyle)) { - Ember.Logger.error(`Service 'markers-styles-renderer' can't get default style settings for '${type}' markers-style.`); + Ember.Logger.error(`Service 'markers-styles-renderer' can't get default style settings for default markers-style.`); return null; } @@ -196,7 +196,10 @@ export default Ember.Service.extend({ calcScale(styleSettings) { let maxSize = this.get('_size'); let max = 0; - let top = 0, bottom = 0, left = 0, right = 0; + let top = 0; + let bottom = 0; + let left = 0; + let right = 0; if (!Ember.isArray(styleSettings)) { let style = styleSettings.style; if (styleSettings.type === 'default') { @@ -215,7 +218,7 @@ export default Ember.Service.extend({ if (styleSettings.get('firstObject.type') === 'default') { iconSize = this.getDefaultMarkerSettings().iconSize; } else { - iconSize = styleSettings.get('firstObject.style.iconSize') + iconSize = styleSettings.get('firstObject.style.iconSize'); } max = Math.max(iconSize[0], iconSize[1]); @@ -233,8 +236,11 @@ export default Ember.Service.extend({ let anchorW = style.iconAnchor[0]; if ((0 - anchorH) < top) { top = (0 - anchorH); } + if ((height - anchorH) > bottom) { bottom = (height - anchorH); } + if ((0 - anchorW) < left) { left = (0 - anchorW); } + if ((width - anchorW) > right) { right = (width - anchorW); } } }); From f407aa38f2ee3d4fb67228384ae9645b17e6985d Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 7 Nov 2023 10:48:11 +0500 Subject: [PATCH 17/33] fix test --- tests/unit/mixins/layer-label-test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/unit/mixins/layer-label-test.js b/tests/unit/mixins/layer-label-test.js index d27b75a0a..8ff82e14a 100644 --- a/tests/unit/mixins/layer-label-test.js +++ b/tests/unit/mixins/layer-label-test.js @@ -16,6 +16,13 @@ test('test method _createStringLabel', function(assert) { center: [51.505, -0.09], zoom: 13 }); + let styleSettings = { + 'style': { + 'marker': { + 'type': 'default', + } + } + }; let settings = { 'options': { 'captionFontColor': '#000000FF', @@ -47,7 +54,8 @@ test('test method _createStringLabel', function(assert) { let subject = LayerLabelObject.create({ leafletMap: leafletMap, showExisting: false, - labelsLayers: [labelsLayer] + labelsLayers: [labelsLayer], + styleSettings: styleSettings }); let _applyFunctionStub = sinon.stub(subject, '_applyFunction'); From edcf541fa543e3ffc3b74a185c3959acf3260e75 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 7 Nov 2023 13:50:14 +0500 Subject: [PATCH 18/33] fix circle --- addon/initializers/leaflet-canvas.js | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/addon/initializers/leaflet-canvas.js b/addon/initializers/leaflet-canvas.js index 65770cb5a..a050e41b2 100644 --- a/addon/initializers/leaflet-canvas.js +++ b/addon/initializers/leaflet-canvas.js @@ -40,6 +40,35 @@ export function initialize() { } }, + /** + @method _updateCircle + Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L302 + Get ctx and call _fillStroke. + */ + _updateCircle: function (layer) { + + if (!this._drawing || layer._empty()) { return; } + + var p = layer._point, + ctx = this._ctx, + r = Math.max(Math.round(layer._radius), 1), + s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; + + if (s !== 1) { + ctx.save(); + ctx.scale(1, s); + } + + ctx.beginPath(); + ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false); + + if (s !== 1) { + ctx.restore(); + } + + this._fillStroke(ctx, layer.options); + }, + /** @method _fillStroke Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L326 From eb2854e66595e4cb40c27c2272da078b000cdaa9 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 7 Nov 2023 13:55:37 +0500 Subject: [PATCH 19/33] fix jscs --- addon/initializers/leaflet-canvas.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/initializers/leaflet-canvas.js b/addon/initializers/leaflet-canvas.js index a050e41b2..52db0d776 100644 --- a/addon/initializers/leaflet-canvas.js +++ b/addon/initializers/leaflet-canvas.js @@ -49,10 +49,10 @@ export function initialize() { if (!this._drawing || layer._empty()) { return; } - var p = layer._point, - ctx = this._ctx, - r = Math.max(Math.round(layer._radius), 1), - s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; + let p = layer._point; + let ctx = this._ctx; + let r = Math.max(Math.round(layer._radius), 1); + let s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; if (s !== 1) { ctx.save(); From 3fac7161fc6fe1865a4eee67d945fea0f5080d6b Mon Sep 17 00:00:00 2001 From: Lytkina Darya Date: Thu, 9 Nov 2023 15:04:48 +0500 Subject: [PATCH 20/33] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B2=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D1=87=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/components/flexberry-identify-file.js | 82 ++++++++++++------- addon/mixins/flexberry-check-file.js | 13 +-- addon/mixins/flexberry-map-model-api.js | 2 +- addon/styles/addon.less | 6 ++ .../themes/default/globals/site.variables | 2 +- .../components/flexberry-identify-file.hbs | 34 ++++++-- 6 files changed, 92 insertions(+), 47 deletions(-) diff --git a/addon/components/flexberry-identify-file.js b/addon/components/flexberry-identify-file.js index 28f65bdc3..4a46da2e7 100644 --- a/addon/components/flexberry-identify-file.js +++ b/addon/components/flexberry-identify-file.js @@ -28,11 +28,26 @@ export default Ember.Component.extend(CheckFileMixin, { */ geometryField2: null, + /** + Necessity of geometry field names (one (with WKT geometry) or two (X,Y coordinates - points only)) + geometryField1 and geometryField2 + For .csv, .xls, .xlsx + */ needGeometryFieldName: false, - acceptFiles: null, + /** + Necessity of geometry type. For .gpx (it contains different types of data and can be transformed to different types of data) + */ + needGeometryType: false, + + /** + Necessity of "not auto" CRS + */ + needCRS: false, + + acceptFiles: '.zip,.GEOJSON,.gml,.xls,.xlsx,.csv,.xml,.gpx,.kml', - importErrorMessage: 'Загруженный файл не соответствует требованиям: ', + importErrorMessage: 'Загруженный файл не соответствует требованиям', emptyErrorMessage: 'Файл не содержит геометрических объектов', @@ -42,11 +57,10 @@ export default Ember.Component.extend(CheckFileMixin, { typeGeometryErrorMessage: 'Указанный тип геометрии противоречит объектам в файле', - warningMessageSRS: 'Укажите верную систему координат, указанную в загружаемом файле. ' + - 'При выборе ошибочной системы координат слой может некорректно отображаться на карте', - warningMessageEmptyGeometry: 'В файле обнаружены объекты без геометрии. Дальнейшая загрузка будет осуществлена без них', + warningMessageAutoCRS: 'У загруженного файла не определена система координат. Выберите систему координат из списка', + emptyGeometryField: 'Укажите название поля с геометрией в файле (WKT/X,Y)', /** @@ -67,18 +81,11 @@ export default Ember.Component.extend(CheckFileMixin, { }); }, - setAcceptFiles() { - if (Ember.isEmpty(this.get('acceptFiles'))) { - this.set('acceptFiles', '.zip,.GEOJSON,.gml,.xls,.xlsx,.csv,.xml,.gps,.kml'); - } - }, - didInsertElement() { this._super(...arguments); this.set('systemCoordinates', this.get('systemCoordinates') || availableCoordinateReferenceSystemsCodesWithCaptions(this)); this.set('coordinate', 'auto'); - this.setAcceptFiles(); this.send('clearFile'); }, @@ -121,7 +128,7 @@ export default Ember.Component.extend(CheckFileMixin, { @method fieldsSet */ - fieldsSet: Ember.observer('file', 'needGeometryFieldName', 'geometryField1', 'geometryField2', function() { + fieldsSet: Ember.observer('file', 'needGeometryFieldName', 'geometryField1', 'geometryField2', function () { let file = this.get('file'); if (this.get('needGeometryFieldName') && !Ember.isNone(file)) { let geometryField1 = this.get('geometryField1'); @@ -134,11 +141,11 @@ export default Ember.Component.extend(CheckFileMixin, { }), /** - Get headers fields from csv or xls file. + Get headers fields from csv or xls|xlsx file. - @method getFieldsFromCsv + @method getFields */ - getFieldsFromCsv() { + getFields() { this.set('_showError', false); let config = Ember.getOwner(this).resolveRegistration('config:environment'); let data = new FormData(); @@ -154,29 +161,27 @@ export default Ember.Component.extend(CheckFileMixin, { processData: false, }).done((response) => { if (response && response.length) { - const items = response.split(','); - this.set('_availableFields', Ember.A(items)); - this.set('needGeometryFieldName', true); + this.set('_availableFields', Ember.A(response)); } else { - this.set('_errorMessage', this.get('importErrorMessage') + this.get('emptyHeaderErrorMessage')); + this.set('_errorMessage', this.get('emptyHeaderErrorMessage')); this.set('_showError', true); - this.set('needGeometryFieldName', false); - this.set('needGeometryType', false); } }).fail(() => { let message = this.get('badFileMessage'); - this.set('_errorMessage', this.get('importErrorMessage') + message); + this.set('_errorMessage', message); this.set('_showError', true); - this.set('needGeometryFieldName', false); - this.set('needGeometryType', false); }); } }, actions: { - onCoordinateChange() { + clearCacheAndPreview() { this.set('_showError', false); this.clearAjax(); + if (this.get('filePreview')) { + this.get('mapApi').getFromApi('leafletMap').fire(`flexberry-map-loadfile${this.get('suffix')}:clear`); + this.set('filePreview', false); + } }, clearFile() { @@ -184,6 +189,7 @@ export default Ember.Component.extend(CheckFileMixin, { this.set('coordinate', 'auto'); this.set('needGeometryFieldName', false); this.set('needGeometryType', false); + this.set('needCRS', false); this.set('geometryField1', null); this.set('geometryField2', null); this.set('geometryFieldFile', null); @@ -201,19 +207,33 @@ export default Ember.Component.extend(CheckFileMixin, { this.$('.ui.button.remove').addClass('hidden'); }, + /** + * Выбор пользователем файла + */ clickFile(e) { let file = e.target.files[0]; + if (!file) { + return; + } + let fileName = file.name; - let ext = fileName.substring(fileName.indexOf('.'), fileName.length); + let ext = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase(); this.set('file', file); - if (ext.toLowerCase() === '.csv' || ext.toLowerCase() === '.xls' || ext.toLowerCase() === '.xlsx') { + if (ext === '.csv' || ext === '.xls' || ext === '.xlsx') { this.set('needGeometryFieldName', true); - this.getFieldsFromCsv(); - this.set('warningMessage', this.get('warningMessageSRS')); + this.getFields(); + } + + if (ext === '.gpx' || ext === '.kml') { + this.set('coordinate', 'EPSG:4326'); + } + + if (ext === '.gpx' || ext === '.gml' || ext === '.csv' || ext === '.xls' || ext === '.xlsx') { + this.set('needCRS', true); } - if (ext.toLowerCase() === '.gpx') { + if (ext === '.gpx') { this.set('needGeometryType', true); } diff --git a/addon/mixins/flexberry-check-file.js b/addon/mixins/flexberry-check-file.js index b7e4a9792..ca59edc3c 100644 --- a/addon/mixins/flexberry-check-file.js +++ b/addon/mixins/flexberry-check-file.js @@ -113,7 +113,7 @@ export default Ember.Mixin.create({ let ajax = this.get('fileLoadAjax'); if (ajax) { if (ajax.readyState === 4 && ajax.status === 200) { - resolve(this.get('fileLoadAjax').responseJSON); + resolve(JSON.parse(this.get('fileLoadAjax').responseText || '{}')); return; } @@ -130,7 +130,7 @@ export default Ember.Mixin.create({ let url = `${config.APP.backendUrls.geomFileValidationUrl}?FileName=${file.name}`; let data = new FormData(); data.append(file.name, file); - data.append('crs', this.get('coordinate')); + data.append('fileCrs', this.get('coordinate')); if (this.get('needGeometryType')) { data.append('typeGeometryLayer', this.get('_geometryType')); @@ -153,11 +153,12 @@ export default Ember.Mixin.create({ processData: false }).done((response) => { this._showHideLoader(false); - if (response && response.features) { - this.set('coordinate', response.definedCrs); - this.set('geometryType', this.getGeometryType(response.features[0].geometry.type)); + let jsonResponse = JSON.parse(response || '{}'); + if (jsonResponse.features) { + this.set('coordinate', jsonResponse.definedCrs); + this.set('geometryType', this.getGeometryType(jsonResponse.features[0].geometry.type)); - resolve(response); + resolve(jsonResponse); } else { reject({ message: this.get('emptyErrorMessage') diff --git a/addon/mixins/flexberry-map-model-api.js b/addon/mixins/flexberry-map-model-api.js index dccf13634..fe7d684bb 100644 --- a/addon/mixins/flexberry-map-model-api.js +++ b/addon/mixins/flexberry-map-model-api.js @@ -1214,7 +1214,7 @@ export default Ember.Mixin.create(SnapDraw, actionsHandler, { return new Ember.RSVP.Promise((resolve, reject) => { Ember.$.ajax({ - url: `${config.APP.backendUrl}/controls/FileUploaderHandler.ashx?FileName=${file.name}`, + url: `${config.APP.backendUrls.fileUploadUrl}?FileName=${file.name}`, type: 'POST', data: data, cache: false, diff --git a/addon/styles/addon.less b/addon/styles/addon.less index 761e66bb5..9ea1cae47 100644 --- a/addon/styles/addon.less +++ b/addon/styles/addon.less @@ -39,6 +39,12 @@ } } +.flexberry-validationsummary.ui.gray.message { + box-shadow: none; + color: @greyText; + border-color: @greyText; +} + /** Fix disappearing checkboxes while scrolling */ diff --git a/addon/styles/themes/default/globals/site.variables b/addon/styles/themes/default/globals/site.variables index dcf669b9c..c6b39d669 100644 --- a/addon/styles/themes/default/globals/site.variables +++ b/addon/styles/themes/default/globals/site.variables @@ -13,7 +13,7 @@ @greencolor: #65A43F; @orangecolor: #EB1C24; @mediumbluecolor: #DDEBFF; - +@greyText: #848E99; /******************************* Components variables diff --git a/addon/templates/components/flexberry-identify-file.hbs b/addon/templates/components/flexberry-identify-file.hbs index 95dea46ec..192f54d80 100644 --- a/addon/templates/components/flexberry-identify-file.hbs +++ b/addon/templates/components/flexberry-identify-file.hbs @@ -23,10 +23,12 @@
{{flexberry-dropdown - class=(concat "fluid geometryType") + class=(concat "no-placeholder fluid geometryType") items=_geometryTypes value=_geometryType displayCaptions=true + placeholder="" + onChange=(action 'clearCacheAndPreview') }}
{{/if}} @@ -34,15 +36,19 @@
{{flexberry-dropdown - class=(concat "fluid geometryField1") + class=(concat "no-placeholder fluid geometryField1") items=_availableFields value=geometryField1 + placeholder="" + onChange=(action 'clearCacheAndPreview') }}
{{flexberry-dropdown - class=(concat "field fluid geometryField2" (if disableCrs " disabled" "")) + class=(concat "no-placeholder fluid geometryField2") items=_availableFields value=geometryField2 + placeholder="" + onChange=(action 'clearCacheAndPreview') }} {{/if}} @@ -52,7 +58,7 @@ items=systemCoordinates value=coordinate displayCaptions=true - onChange=(action 'onCoordinateChange') + onChange=(action 'clearCacheAndPreview') class="scale-value fluid" }} @@ -63,7 +69,7 @@ {{flexberry-button iconClass=(if filePreview 'icon-guideline-hide' 'icon-guideline-show') click=(action "showFileLayer") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.preview.caption") }} @@ -72,7 +78,7 @@ class='ml-20' iconClass='icon-guideline-layers-info' click=(action "identificationFile") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.identify.caption") }} @@ -81,12 +87,23 @@ class='ml-20' iconClass='icon-guideline-goout' click=(action "createLayerByFile") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.create-layer.caption") }} {{/if}} {{/if}} + +{{#if (and needCRS (eq coordinate 'auto'))}} + {{ui-message + type="error" + closeable=false + visible=true + class=(concat "flexberry-validationsummary gray") + message=warningMessageAutoCRS + }} +{{/if}} + {{#if _showError}} {{ui-message type="error" @@ -94,4 +111,5 @@ visible=_showError message=_errorMessage }} -{{/if}} \ No newline at end of file +{{/if}} + From ef30cefc238757e7f8fe1821d626f69e0f123706 Mon Sep 17 00:00:00 2001 From: Lytkina Darya Date: Thu, 9 Nov 2023 15:21:47 +0500 Subject: [PATCH 21/33] test --- tests/unit/mixins/flexberry-map-model-api-test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/mixins/flexberry-map-model-api-test.js b/tests/unit/mixins/flexberry-map-model-api-test.js index e8694c27e..fb4e18c09 100644 --- a/tests/unit/mixins/flexberry-map-model-api-test.js +++ b/tests/unit/mixins/flexberry-map-model-api-test.js @@ -23,7 +23,9 @@ test('uploadFile should send post request with fileName and data to backend and resolveRegistration() { return { 'APP': { - 'backendUrl': 'stubbackend' + 'backendUrls': { + 'fileUploadUrl': 'stubbackend' + } } }; } @@ -37,7 +39,7 @@ test('uploadFile should send post request with fileName and data to backend and assert.ok(result instanceof Ember.RSVP.Promise); assert.ok(server.requests[0].requestBody.has('testFile')); - assert.equal(server.requests[0].url, 'stubbackend/controls/FileUploaderHandler.ashx?FileName=testFile'); + assert.equal(server.requests[0].url, 'stubbackend?FileName=testFile'); result.then((e) => { assert.equal(e, 'uploadfileresponse'); done(); From fdf8ded9b52943e382b4c3f82be5e6824b2f76ae Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Thu, 9 Nov 2023 16:26:42 +0500 Subject: [PATCH 22/33] remove developing addon --- index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/index.js b/index.js index 950939542..41264224b 100644 --- a/index.js +++ b/index.js @@ -4,11 +4,6 @@ module.exports = { name: 'ember-flexberry-gis', - isDevelopingAddon() { - return true; - }, - - included: function (app) { this._super.included.apply(this._super, arguments); From be9783de5a32ce92994c4a0e25549b64229c2fc3 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 7 Nov 2023 13:50:14 +0500 Subject: [PATCH 23/33] fix circle --- addon/initializers/leaflet-canvas.js | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/addon/initializers/leaflet-canvas.js b/addon/initializers/leaflet-canvas.js index 65770cb5a..a050e41b2 100644 --- a/addon/initializers/leaflet-canvas.js +++ b/addon/initializers/leaflet-canvas.js @@ -40,6 +40,35 @@ export function initialize() { } }, + /** + @method _updateCircle + Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L302 + Get ctx and call _fillStroke. + */ + _updateCircle: function (layer) { + + if (!this._drawing || layer._empty()) { return; } + + var p = layer._point, + ctx = this._ctx, + r = Math.max(Math.round(layer._radius), 1), + s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; + + if (s !== 1) { + ctx.save(); + ctx.scale(1, s); + } + + ctx.beginPath(); + ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false); + + if (s !== 1) { + ctx.restore(); + } + + this._fillStroke(ctx, layer.options); + }, + /** @method _fillStroke Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L326 From 4a591001e9150de99deb83584aa9389933f6d3d1 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 7 Nov 2023 13:55:37 +0500 Subject: [PATCH 24/33] fix jscs --- addon/initializers/leaflet-canvas.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/initializers/leaflet-canvas.js b/addon/initializers/leaflet-canvas.js index a050e41b2..52db0d776 100644 --- a/addon/initializers/leaflet-canvas.js +++ b/addon/initializers/leaflet-canvas.js @@ -49,10 +49,10 @@ export function initialize() { if (!this._drawing || layer._empty()) { return; } - var p = layer._point, - ctx = this._ctx, - r = Math.max(Math.round(layer._radius), 1), - s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; + let p = layer._point; + let ctx = this._ctx; + let r = Math.max(Math.round(layer._radius), 1); + let s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; if (s !== 1) { ctx.save(); From cf2c7703e4f9c850d4db5baae4103d921a9b30e3 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 14 Nov 2023 18:05:51 +0500 Subject: [PATCH 25/33] fix legend for wfs and wms-wfs --- .../legends/-private/vector-legend.js | 4 + .../legends/layers-styles/-private/base.js | 3 +- .../legends/layers-styles/simple.js | 44 +++--- addon/markers-styles/image.js | 94 +----------- addon/services/markers-styles-renderer.js | 137 ++++++++---------- .../themes/default/modules/sidebar.overrides | 18 +++ .../components/flexberry-maplayer.hbs | 12 +- .../legends/-private/vector-legend.hbs | 2 +- .../legends/layers-styles/simple.hbs | 36 +++-- 9 files changed, 149 insertions(+), 201 deletions(-) diff --git a/addon/components/legends/-private/vector-legend.js b/addon/components/legends/-private/vector-legend.js index fb0019561..2b772c4ee 100644 --- a/addon/components/legends/-private/vector-legend.js +++ b/addon/components/legends/-private/vector-legend.js @@ -23,6 +23,10 @@ export default BaseLegendComponent.extend({ @readOnly */ _styleSettingsRelatedComponentName: Ember.computed('layer.settingsAsObject.styleSettings.type', function() { + if (this.get('layer.type') === 'wms-wfs') { + return `legends/layers-styles/${this.get('layer.settingsAsObject.wfs.styleSettings.type')}`; + } + return `legends/layers-styles/${this.get('layer.settingsAsObject.styleSettings.type')}`; }) }); diff --git a/addon/components/legends/layers-styles/-private/base.js b/addon/components/legends/layers-styles/-private/base.js index e3d80eadc..70d502b52 100644 --- a/addon/components/legends/layers-styles/-private/base.js +++ b/addon/components/legends/layers-styles/-private/base.js @@ -18,7 +18,8 @@ const flexberryClassNames = { imageWrapper: 'layer-legend-image-wrapper', image: 'layer-legend-image', caption: 'layer-legend-caption', - zoom: 'layer-legend-zoom' + zoom: 'layer-legend-zoom', + marker: 'layer-legend-marker' }; /** diff --git a/addon/components/legends/layers-styles/simple.js b/addon/components/legends/layers-styles/simple.js index ef7ce9f54..fc3aa59e8 100644 --- a/addon/components/legends/layers-styles/simple.js +++ b/addon/components/legends/layers-styles/simple.js @@ -74,12 +74,23 @@ export default BaseLayerStyleLegendComponent.extend({ } if (this.get('_markersCanBeDisplayed')) { - let style = styleRule.styleSettings.style.marker; - let canvas = this.$(`canvas.markers${index}`)[0]; - this._markerLegendRenderer(style, canvas); + let styles = styleRule.styleSettings.style.marker; + if (styles.hasOwnProperty('scale')) { + return; + } + + let markersStylesRenderer = this.get('_markersStylesRenderer'); + let scale = markersStylesRenderer.calcScale(styles); + styles.scale = scale; + Ember.set(styleRule, 'width', scale.size); + Ember.set(styleRule, 'height', scale.size); + + styles.forEach(style => { + markersStylesRenderer.getStyle(scale, style); + }); + } }); - } else { this._withoutStyleRules(); } @@ -93,9 +104,17 @@ export default BaseLayerStyleLegendComponent.extend({ } if (this.get('_markersCanBeDisplayed')) { - let styleSettings = Ember.isNone(this.parentView.layer.legendStyle) ? this.get('styleSettings.style.marker') : this.parentView.layer.legendStyle; - let canvas = this.$('canvas.markers')[0]; - this._markerLegendRenderer(styleSettings, canvas); + let styles = Ember.isNone(this.parentView.layer.legendStyle) ? this.get('styleSettings.style.marker') : this.parentView.layer.legendStyle; + if (styles.hasOwnProperty('scale')) { + return; + } + + let markersStylesRenderer = this.get('_markersStylesRenderer'); + let scale = markersStylesRenderer.calcScale(styles); + styles.scale = scale; + this.set('width', scale.size); + this.set('height', scale.size); + markersStylesRenderer.getStyle(scale, styles); } }, @@ -114,14 +133,5 @@ export default BaseLayerStyleLegendComponent.extend({ canvas: canvas, target: 'legend' }); - }, - - _markerLegendRenderer(styleSettings, canvas) { - let markersStylesRenderer = this.get('_markersStylesRenderer'); - markersStylesRenderer.renderOnCanvas({ - styleSettings: styleSettings, - canvas: canvas, - target: 'legend' - }); - }, + } }); diff --git a/addon/markers-styles/image.js b/addon/markers-styles/image.js index 99e514616..ee2c1ad5c 100644 --- a/addon/markers-styles/image.js +++ b/addon/markers-styles/image.js @@ -36,7 +36,9 @@ export default BaseMarkerStyle.extend({ shadowSize: [41, 41], // Shadow icon anchor relative to it's size. - shadowAnchor: [12, 41] + shadowAnchor: [12, 41], + + iconType: 'default' }; }, @@ -52,95 +54,5 @@ export default BaseMarkerStyle.extend({ if (Ember.isNone(marker.styleIsSet) || !marker.styleIsSet) { marker.setIcon(new L.Icon(style)); } - }, - - getAnchor(style) { - let aW = 0.5; - let aH = 0.5; - - if (!Ember.isNone(style)) { - aW = style.iconAnchor[0]; - aH = style.iconAnchor[1]; - } - - return [Math.round(Number(style.iconSize[0]) * aW), Math.round(Number(style.iconSize[1]) * aH)]; - }, - - /** - Renderes marker-style preview on the specified canvas element. - - @method renderOnCanvas - @param {Object} options Method options. - @param {Canvas} options.canvas Canvas element on which marker-style preview must be rendered. - @param {Object} options.style Hash containing style settings. - @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). - */ - renderOnCanvas({ canvas, style, target, scale }) { - let width = canvas.width; - let height = canvas.height; - let ctx = canvas.getContext('2d'); - - // Clear canvas. - ctx.clearRect(0, 0, width, height); - - var iconImage = new Image(); - let _this = this; - iconImage.onload = function() { - // Draw loaded image. - let iconWidth = style.iconSize[0] || iconImage.width; - let iconHeight = style.iconSize[1] || iconImage.height; - let xOffset = 0; - let yOffset = 0; - - let anchor = _this.getAnchor(style); - xOffset = width / 2 - anchor[0] * scale; - yOffset = height / 2 - anchor[1] * scale; - - let drawIconImage = function() { - ctx.drawImage(iconImage, xOffset, yOffset, iconWidth * scale, iconHeight * scale); - }; - - if (Ember.isBlank(style.shadowUrl)) { - drawIconImage(); - } else { - let shadowImage = new Image(); - shadowImage.onload = function() { - // Draw shadow icon. - let shadowWidth = style.shadowSize[0] || shadowImage.width; - let sadowHeight = style.shadowSize[1] || shadowImage.height; - - let xShadowOffset = style.iconAnchor[0] - style.shadowAnchor[0]; - let yShadowOffset = style.iconAnchor[1] - style.shadowAnchor[1]; - ctx.drawImage(shadowImage, xOffset + xShadowOffset, yOffset + yShadowOffset, shadowWidth * scale, sadowHeight * scale); - - // Draw marker icon. - drawIconImage(); - }; - - shadowImage.onerror = function() { - // Shadow is optional, so draw marker icon anyway. - drawIconImage(); - }; - - // Set shadow image src to start loading. - shadowImage.src = style.shadowUrl; - } - }; - - iconImage.onerror = function() { - // Draw red cross instead of image. - ctx.moveTo(0, 0); - ctx.lineTo(width, height); - - ctx.moveTo(width, 0); - ctx.lineTo(0, height); - - ctx.lineWidth = 4; - ctx.strokeStyle = '#ff0000'; - ctx.stroke(); - }; - - // Set image src to start loading. - iconImage.src = style.iconUrl; } }); diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index 9fd8400f2..8dff08dc4 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -133,58 +133,33 @@ export default Ember.Service.extend({ markerStyle.renderOnLeafletMarker({ marker, style }); }, - /** - Renderes marker-style preview on the specified canvas element. + calcTransform(top, bottom, left, right) { + let size = (Math.max(Math.abs(top) + Math.abs(bottom), Math.abs(left) + Math.abs(right))); - @method renderOnCanvas - @param {Object} options Method options. - @param {Canvas} options.canvas Canvas element on which layer-style preview must be rendered. - @param {Object} options.styleSettings Hash containing style settings. - @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). - */ - renderOnCanvas({ canvas, styleSettings, target, scale }) { - target = target || 'preview'; + let topOffsetCenter = parseFloat(((Math.abs(top) / (Math.abs(top) + Math.abs(bottom))) * 100).toFixed(2)); + let leftOffsetCenter = parseFloat(((Math.abs(left) / (Math.abs(left) + Math.abs(right))) * 100).toFixed(2)); - if (Ember.isArray(styleSettings)) { - if (!scale && styleSettings.length > 1) { - scale = this.calcScale(styleSettings); - } + return { size, topOffsetCenter, leftOffsetCenter}; + }, - styleSettings.forEach(settings => { - let type = Ember.get(settings, 'type'); - let style = Ember.get(settings, 'style'); + transform(style, top, bottom, left, right) { + if (!Ember.isNone(style)) { + let width = style.iconSize[0]; + let height = style.iconSize[1]; + let anchorH = style.iconAnchor[1]; + let anchorW = style.iconAnchor[0]; - let markerStyle = this._getMarkerStyle(type); - if (Ember.isNone(markerStyle)) { - Ember.Logger.error(`Service 'markers-styles-renderer' can't render '${type}' markers-style on canvas.`); - return; - } + if ((0 - anchorH) < top) { top = (0 - anchorH); } - markerStyle.renderOnCanvas({ canvas, style, target, scale }); - }); - } else { - let type = Ember.get(styleSettings, 'type'); - let style = Ember.get(styleSettings, 'style'); + if ((height - anchorH) > bottom) { bottom = (height - anchorH); } - let markerStyle = this._getMarkerStyle(type); - if (Ember.isNone(markerStyle)) { - Ember.Logger.error(`Service 'markers-styles-renderer' can't render '${type}' markers-style on canvas.`); - return; - } + if ((0 - anchorW) < left) { left = (0 - anchorW); } - markerStyle.renderOnCanvas({ canvas, style, target, scale }); + if ((width - anchorW) > right) { right = (width - anchorW); } } - }, - /** - Size canvas for legend. - - @property size - @type Number - @default 24 - @private - */ - _size: 24, + return { top, bottom, left, right }; + }, /** Calculate scale for canvas of legend. @@ -194,34 +169,19 @@ export default Ember.Service.extend({ @return {Object} Hash containing style settings. */ calcScale(styleSettings) { - let maxSize = this.get('_size'); - let max = 0; let top = 0; let bottom = 0; let left = 0; let right = 0; + let reasult; if (!Ember.isArray(styleSettings)) { let style = styleSettings.style; if (styleSettings.type === 'default') { style = this.getDefaultMarkerSettings(); } - let iconWidth = style.iconSize[0]; - let iconHeight = style.iconSize[1]; - return iconWidth > maxSize || iconHeight > maxSize ? - Math.min(maxSize / iconWidth, maxSize / iconHeight) : - 1; - } - - if (styleSettings.length === 1) { - let iconSize; - if (styleSettings.get('firstObject.type') === 'default') { - iconSize = this.getDefaultMarkerSettings().iconSize; - } else { - iconSize = styleSettings.get('firstObject.style.iconSize'); - } - - max = Math.max(iconSize[0], iconSize[1]); + let value = this.transform(style, top, bottom, left, right); + reasult = this.calcTransform(value.top, value.bottom, value.left, value.right); } else { styleSettings.forEach((settings) => { let style = settings.style; @@ -229,29 +189,50 @@ export default Ember.Service.extend({ style = this.getDefaultMarkerSettings(); } - if (!Ember.isNone(style)) { - let width = style.iconSize[0]; - let height = style.iconSize[1]; - let anchorH = style.iconAnchor[1]; - let anchorW = style.iconAnchor[0]; - - if ((0 - anchorH) < top) { top = (0 - anchorH); } - - if ((height - anchorH) > bottom) { bottom = (height - anchorH); } + let value = this.transform(style, top, bottom, left, right); + top = value.top; + bottom = value.bottom; + left = value.left; + right = value.right; + }); - if ((0 - anchorW) < left) { left = (0 - anchorW); } + reasult = this.calcTransform(top, bottom, left, right); + } - if ((width - anchorW) > right) { right = (width - anchorW); } - } - }); + return reasult; + }, - max = (Math.max(Math.abs(top), Math.abs(bottom), Math.abs(left), Math.abs(right))) * 2; + getStyle(scale, settings) { + if (settings.cssStyle) { + return; } - if (max <= maxSize) { - return 1; + let size = scale.size; + let style = settings.style; + if (settings.type === 'default') { + style = this.getDefaultMarkerSettings(); } - return maxSize / max; + let iconHeight = style.iconSize[1]; + let iconWidth = style.iconSize[0]; + + let anchorHeight = style.iconAnchor[1]; + let anchorWidth = style.iconAnchor[0]; + + let topOffsetCenter = scale.topOffsetCenter; + let leftOffsetCenter = scale.leftOffsetCenter; + + let top = (topOffsetCenter - ((anchorHeight / size) * 100)).toFixed(2); + let left = (leftOffsetCenter - ((anchorWidth / size) * 100)).toFixed(2); + + let height = ((iconHeight / size) * 100).toFixed(2); + let width = ((iconWidth / size) * 100).toFixed(2); + + let cssStyle = { + style: `height: ${height}%; width: ${width}%; top: ${top}%; left: ${left}%;`, + src: style.iconUrl + }; + + Ember.set(settings, 'cssStyle', cssStyle); } }); diff --git a/addon/styles/themes/default/modules/sidebar.overrides b/addon/styles/themes/default/modules/sidebar.overrides index 8538f86a5..41c2cc018 100644 --- a/addon/styles/themes/default/modules/sidebar.overrides +++ b/addon/styles/themes/default/modules/sidebar.overrides @@ -282,6 +282,17 @@ .layer-legend-zoom { width: 100%; padding: 2px; + display: flex; + .layer-legend-marker { + display: flex; + flex-direction: column; + vertical-align: middle; + align-items: center; + justify-content: center; + position: relative; + width:24px; + height:24px; + } } .layer-legend-image, @@ -290,6 +301,13 @@ float: left; } .layer-legend-image { + position: relative; + max-width: 24px; + max-height: 24px; + .icon-image { + position: absolute; + pointer-events: none; + } } .layer-legend-caption { color: @textColor; diff --git a/addon/templates/components/flexberry-maplayer.hbs b/addon/templates/components/flexberry-maplayer.hbs index 724d0b9c0..706cc9b50 100644 --- a/addon/templates/components/flexberry-maplayer.hbs +++ b/addon/templates/components/flexberry-maplayer.hbs @@ -230,9 +230,15 @@ }} {{/if}} {{#if (and layer.legendCanBeDisplayed hasBeenExpanded)}} - {{component (concat "legends/" layer.type "-legend") - layer=layer - }} + {{#if (and (eq layer.type "wms-wfs") (eq layer.settingsAsObject.remoteStyles false) )}} + {{component (concat "legends/wfs-legend") + layer=layer + }} + {{else}} + {{component (concat "legends/" layer.type "-legend") + layer=layer + }} + {{/if}} {{/if}} {{/yield-slot}} {{/block-slot}} diff --git a/addon/templates/components/legends/-private/vector-legend.hbs b/addon/templates/components/legends/-private/vector-legend.hbs index a9a6ed6f9..e25c8c533 100644 --- a/addon/templates/components/legends/-private/vector-legend.hbs +++ b/addon/templates/components/legends/-private/vector-legend.hbs @@ -1,7 +1,7 @@ {{#if (known-for-type "component" _styleSettingsRelatedComponentName)}} {{component _styleSettingsRelatedComponentName styleSettings=layer.settingsAsObject.styleSettings - legendSettings=layer.settingsAsObject.legendSettings + legendSettings=(if (eq layer.type "wms-wfs") layer.settingsAsObject.wfs.legendSettings layer.settingsAsObject.legendSettings) showCaption=showLayerName caption=layer.name styleRules=layer.styleRules diff --git a/addon/templates/components/legends/layers-styles/simple.hbs b/addon/templates/components/legends/layers-styles/simple.hbs index 934529ea4..9347b9706 100644 --- a/addon/templates/components/legends/layers-styles/simple.hbs +++ b/addon/templates/components/legends/layers-styles/simple.hbs @@ -16,18 +16,34 @@ {{/if}} {{#if _markersCanBeDisplayed}} {{#if (and styleRules (gt styleRules.length 0))}} - {{#each styleRules as |styleRule index|}} -
- - + {{#each styleRules as |styleRule index|}} +
+
+
+ {{#each styleRule.styleSettings.style.marker as |settings|}} + + {{/each}} +
- {{/each}} - {{else}} - - {{#if showCaption}} - - {{/if}} + +
+ {{/each}} + {{else}} +
+
+
+ +
+
+
+ {{#if showCaption}} + {{/if}} + {{/if}} {{/if}}
\ No newline at end of file From 054b386375139223cd53a6229cb6bcb81eed2342 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Tue, 14 Nov 2023 18:11:18 +0500 Subject: [PATCH 26/33] fix jscs --- addon/services/markers-styles-renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index 8dff08dc4..ea619fe43 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -139,7 +139,7 @@ export default Ember.Service.extend({ let topOffsetCenter = parseFloat(((Math.abs(top) / (Math.abs(top) + Math.abs(bottom))) * 100).toFixed(2)); let leftOffsetCenter = parseFloat(((Math.abs(left) / (Math.abs(left) + Math.abs(right))) * 100).toFixed(2)); - return { size, topOffsetCenter, leftOffsetCenter}; + return { size, topOffsetCenter, leftOffsetCenter }; }, transform(style, top, bottom, left, right) { From 330b19e962987f185d4ef9ed97aa89ad7e3e1d36 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Wed, 15 Nov 2023 11:53:00 +0500 Subject: [PATCH 27/33] fix --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 41264224b..72f9df65b 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,10 @@ module.exports = { name: 'ember-flexberry-gis', + isDevelopingAddon() { + return true; + }, + included: function (app) { this._super.included.apply(this._super, arguments); From e2c57062bd26c1d8d656aa105c832320c72c3eb2 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Wed, 15 Nov 2023 12:59:00 +0500 Subject: [PATCH 28/33] fix draw error --- .../flexberry-edit-layer-feature.js | 12 ++++--- addon/components/geometry-add-modes/draw.js | 14 ++++---- addon/initializers/leaflet-path.js | 34 ++++++++++--------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/addon/components/flexberry-edit-layer-feature.js b/addon/components/flexberry-edit-layer-feature.js index b87fc08f6..0b023828a 100644 --- a/addon/components/flexberry-edit-layer-feature.js +++ b/addon/components/flexberry-edit-layer-feature.js @@ -778,8 +778,10 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, // Removing a layer from the map that was added for edit mode if (leafletMap.hasLayer(layer)) { - layer.setStyle(layer.defaultFeatureStyle); - layer.styleIsSet = layer.defaultSetStyle; + if (!this.get('isLayerCopy')) { + layer.setStyle(layer.defaultFeatureStyle); + layer.styleIsSet = layer.defaultSetStyle; + } if (this.get('isLayerCopy')) { leafletMap.removeLayer(layer); @@ -1172,8 +1174,10 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, leafletObject.editLayer(layer); if (leafletMap.hasLayer(layer)) { - layer.setStyle(layer.defaultFeatureStyle); - layer.styleIsSet = layer.defaultSetStyle; + if (!this.get('isLayerCopy')) { + layer.setStyle(layer.defaultFeatureStyle); + layer.styleIsSet = layer.defaultSetStyle; + } if (this.get('isLayerCopy')) { // Deleting a copy of an edited layer from the map diff --git a/addon/components/geometry-add-modes/draw.js b/addon/components/geometry-add-modes/draw.js index 8214e39a0..b925f81de 100644 --- a/addon/components/geometry-add-modes/draw.js +++ b/addon/components/geometry-add-modes/draw.js @@ -306,12 +306,14 @@ let FlexberryGeometryAddModeDrawComponent = Ember.Component.extend({ } let label = this.get('_dragLayer._label'); - let zoom = Number(this.get('leafletMap').getZoom().toFixed(1)); - let labelZooms = label.filter(l => { return (l.minZoom == null || l.minZoom <= zoom) && (l.maxZoom == null || l.maxZoom >= zoom); }); - if (labelZooms.length > 0) { - let labelZoom = labelZooms[0]; - newCoords = moveCoords(labelZoom.getLatLng()); - labelZoom.setLatLng(newCoords); + if (label) { + let zoom = Number(this.get('leafletMap').getZoom().toFixed(1)); + let labelZooms = label.filter(l => { return (l.minZoom == null || l.minZoom <= zoom) && (l.maxZoom == null || l.maxZoom >= zoom); }); + if (labelZooms.length > 0) { + let labelZoom = labelZooms[0]; + newCoords = moveCoords(labelZoom.getLatLng()); + labelZoom.setLatLng(newCoords); + } } }; diff --git a/addon/initializers/leaflet-path.js b/addon/initializers/leaflet-path.js index 30ccd35bf..f97490556 100644 --- a/addon/initializers/leaflet-path.js +++ b/addon/initializers/leaflet-path.js @@ -6,25 +6,27 @@ import Ember from 'ember'; export function initialize() { let setStyle = { setStyle: function (style) { - if (this.options.count) { - for (let i = 0; i < this.options.count; i++) { - if (!style.count) { - this.setStyleCustom(this, this.options[i], style); - } else { - L.Path.prototype.setStyle.call(this, style); + if (style) { + if (this.options.count) { + for (let i = 0; i < this.options.count; i++) { + if (!style.count) { + this.setStyleCustom(this, this.options[i], style); + } else { + L.Path.prototype.setStyle.call(this, style); + } } + } else { + L.Path.prototype.setStyle.call(this, style); } - } else { - L.Path.prototype.setStyle.call(this, style); - } - if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { - this.layerModel.legendStyle = { - type: 'simple', - style: { - path: style - } - }; + if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { + this.layerModel.legendStyle = { + type: 'simple', + style: { + path: style + } + }; + } } return this; From 3c72cfdb9e6dc2a4ec7292abb4392ba64c852628 Mon Sep 17 00:00:00 2001 From: Abramova Snezhana Date: Wed, 15 Nov 2023 14:35:26 +0500 Subject: [PATCH 29/33] fix legend via layer-model --- .../legends/-private/vector-legend.js | 8 +-- addon/layers/-private/base.js | 30 +++++++++++ addon/layers/wms-wfs.js | 42 +++++++++++++++ addon/mixins/layer-model.js | 51 +++++++++++++++++++ addon/services/markers-styles-renderer.js | 8 +-- .../components/flexberry-maplayer.hbs | 12 ++--- .../legends/-private/vector-legend.hbs | 2 +- index.js | 4 -- 8 files changed, 133 insertions(+), 24 deletions(-) diff --git a/addon/components/legends/-private/vector-legend.js b/addon/components/legends/-private/vector-legend.js index 2b772c4ee..b9c347d20 100644 --- a/addon/components/legends/-private/vector-legend.js +++ b/addon/components/legends/-private/vector-legend.js @@ -22,11 +22,7 @@ export default BaseLegendComponent.extend({ @private @readOnly */ - _styleSettingsRelatedComponentName: Ember.computed('layer.settingsAsObject.styleSettings.type', function() { - if (this.get('layer.type') === 'wms-wfs') { - return `legends/layers-styles/${this.get('layer.settingsAsObject.wfs.styleSettings.type')}`; - } - - return `legends/layers-styles/${this.get('layer.settingsAsObject.styleSettings.type')}`; + _styleSettingsRelatedComponentName: Ember.computed('layer.styleSettingsTypeForLegend', function() { + return `legends/layers-styles/${this.get('layer.styleSettingsTypeForLegend')}`; }) }); diff --git a/addon/layers/-private/base.js b/addon/layers/-private/base.js index c91dfc0f4..23b5385be 100644 --- a/addon/layers/-private/base.js +++ b/addon/layers/-private/base.js @@ -142,6 +142,36 @@ export default Ember.Object.extend({ return settings; }, + /** + Type of legend. + @property getLegendType + @type String + @readOnly + */ + getLegendType(type, settingsAsObject) { + return type; + }, + + /** + Settings of legend. + @property getLegendSettings + @type Object + @readOnly + */ + getLegendSettings(settingsAsObject) { + return settingsAsObject.legendSettings; + }, + + /** + Type of legend from style settings. + @property getStyleSettingsTypeForLegend + @type String + @readOnly + */ + getStyleSettingsTypeForLegend(settingsAsObject) { + return settingsAsObject.styleSettings.type; + }, + /** Creates new settings object (with settings related to layer-type) from the specified CSW record. diff --git a/addon/layers/wms-wfs.js b/addon/layers/wms-wfs.js index 291b311de..6719cdcbe 100644 --- a/addon/layers/wms-wfs.js +++ b/addon/layers/wms-wfs.js @@ -56,6 +56,48 @@ export default WmsLayer.extend({ return settings; }, + /** + Type of legend. + @property getLegendType + @type String + @readOnly + */ + getLegendType(type, settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return 'wfs'; + } + + return type; + }, + + /** + Settings of legend. + @property getLegendSettings + @type Object + @readOnly + */ + getLegendSettings(settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return settingsAsObject.wfs.legendSettings; + } + + return settingsAsObject.legendSettings; + }, + + /** + Type of legend from style settings. + @property getStyleSettingsTypeForLegend + @type String + @readOnly + */ + getStyleSettingsTypeForLegend(settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return settingsAsObject.wfs.styleSettings.type; + } + + return settingsAsObject.styleSettings.type; + }, + /** Creates new search settings object (with search settings related to layer-type). diff --git a/addon/mixins/layer-model.js b/addon/mixins/layer-model.js index c2b55074b..2bcdea803 100644 --- a/addon/mixins/layer-model.js +++ b/addon/mixins/layer-model.js @@ -88,6 +88,57 @@ export default Ember.Mixin.create({ } }, + /** + Type of legend. + @property legendType + @type String + @readOnly + */ + legendType: Ember.computed('isDeleted', 'type', 'settingsAsObject.legendSettings', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let legendType = layerClassFactory.getLegendType(this.get('type'), this.get('settingsAsObject')); + + return legendType; + }), + + /** + Settings of legend. + @property legendSettings + @type Object + @readOnly + */ + legendSettings: Ember.computed('isDeleted', 'type', 'settingsAsObject.legendSettings', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let legendSettings = layerClassFactory.getLegendSettings(this.get('settingsAsObject')); + + return legendSettings; + }), + + /** + Type of legend from style settings. + @property styleSettingsForLegend + @type String + @readOnly + */ + styleSettingsTypeForLegend: Ember.computed('isDeleted', 'type', 'settingsAsObject.styleSettings.type', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let styleSettingsTypeForLegend = layerClassFactory.getStyleSettingsTypeForLegend(this.get('settingsAsObject')); + + return styleSettingsTypeForLegend; + }), + /** Flag: indicates whether layer can be identified. @property canBeIdentified diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index ea619fe43..0247d7c92 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -173,7 +173,7 @@ export default Ember.Service.extend({ let bottom = 0; let left = 0; let right = 0; - let reasult; + let result; if (!Ember.isArray(styleSettings)) { let style = styleSettings.style; if (styleSettings.type === 'default') { @@ -181,7 +181,7 @@ export default Ember.Service.extend({ } let value = this.transform(style, top, bottom, left, right); - reasult = this.calcTransform(value.top, value.bottom, value.left, value.right); + result = this.calcTransform(value.top, value.bottom, value.left, value.right); } else { styleSettings.forEach((settings) => { let style = settings.style; @@ -196,10 +196,10 @@ export default Ember.Service.extend({ right = value.right; }); - reasult = this.calcTransform(top, bottom, left, right); + result = this.calcTransform(top, bottom, left, right); } - return reasult; + return result; }, getStyle(scale, settings) { diff --git a/addon/templates/components/flexberry-maplayer.hbs b/addon/templates/components/flexberry-maplayer.hbs index 706cc9b50..8d156cf2d 100644 --- a/addon/templates/components/flexberry-maplayer.hbs +++ b/addon/templates/components/flexberry-maplayer.hbs @@ -230,15 +230,9 @@ }} {{/if}} {{#if (and layer.legendCanBeDisplayed hasBeenExpanded)}} - {{#if (and (eq layer.type "wms-wfs") (eq layer.settingsAsObject.remoteStyles false) )}} - {{component (concat "legends/wfs-legend") - layer=layer - }} - {{else}} - {{component (concat "legends/" layer.type "-legend") - layer=layer - }} - {{/if}} + {{component (concat "legends/" layer.legendType "-legend") + layer=layer + }} {{/if}} {{/yield-slot}} {{/block-slot}} diff --git a/addon/templates/components/legends/-private/vector-legend.hbs b/addon/templates/components/legends/-private/vector-legend.hbs index e25c8c533..ab0b26d37 100644 --- a/addon/templates/components/legends/-private/vector-legend.hbs +++ b/addon/templates/components/legends/-private/vector-legend.hbs @@ -1,7 +1,7 @@ {{#if (known-for-type "component" _styleSettingsRelatedComponentName)}} {{component _styleSettingsRelatedComponentName styleSettings=layer.settingsAsObject.styleSettings - legendSettings=(if (eq layer.type "wms-wfs") layer.settingsAsObject.wfs.legendSettings layer.settingsAsObject.legendSettings) + legendSettings=layer.legendSettings showCaption=showLayerName caption=layer.name styleRules=layer.styleRules diff --git a/index.js b/index.js index 72f9df65b..41264224b 100644 --- a/index.js +++ b/index.js @@ -4,10 +4,6 @@ module.exports = { name: 'ember-flexberry-gis', - isDevelopingAddon() { - return true; - }, - included: function (app) { this._super.included.apply(this._super, arguments); From cb6dd59e060d6688019faead76519ce85efabdbe Mon Sep 17 00:00:00 2001 From: Lytkina Darya Date: Wed, 15 Nov 2023 16:28:51 +0500 Subject: [PATCH 30/33] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/components/flexberry-edit-layer-feature.js | 7 ++++--- addon/components/flexberry-search-panel.js | 4 ++++ addon/components/layers/wfs-layer.js | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addon/components/flexberry-edit-layer-feature.js b/addon/components/flexberry-edit-layer-feature.js index 0b023828a..0b128d6ca 100644 --- a/addon/components/flexberry-edit-layer-feature.js +++ b/addon/components/flexberry-edit-layer-feature.js @@ -932,9 +932,11 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, geoWebCache = leafletObject._url.slice(0, indexGeoserver + 10) + '/gwc/rest/seed/'; } - if (!Ember.isNone(geoWebCache)) { + let crsName = leafletObject.wmsParams.crs || leafletObject.options.crs.code; + + if (!Ember.isNone(geoWebCache) && !Ember.isNone(crsName)) { let url = geoWebCache + workspace + ':' + layer; - let gridSetId = leafletObject.wmsParams.crs + '_' + leafletObject.wmsParams.width; + let gridSetId = crsName + '_' + leafletObject.wmsParams.width; let leafletMap = this.get('leafletMap'); let zoom = Math.trunc(leafletMap.getZoom()); let zoomStart = zoom - 1 > 0 ? zoom - 1 : zoom; @@ -945,7 +947,6 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, parameterStyles = `parameter_STYLES=${workspace}:${styles}&`; } - let crsName = leafletObject.wmsParams.crs; let crs; if (!Ember.isNone(crsName)) { crs = getLeafletCrs('{ "code": "' + crsName.toUpperCase() + '", "definition": "" }', this); diff --git a/addon/components/flexberry-search-panel.js b/addon/components/flexberry-search-panel.js index 1cf91754e..23df28355 100644 --- a/addon/components/flexberry-search-panel.js +++ b/addon/components/flexberry-search-panel.js @@ -184,6 +184,8 @@ export default Ember.Component.extend({ actions: { querySearch() { + this.sendAction('clearSearch'); + if (this.get('attrVisible')) { if (Ember.isNone(this.get('_selectedLayer'))) { this.set('errorMessage', this.get('i18n').t('components.flexberry-search.error-message-empty-selected-layer')); @@ -275,6 +277,8 @@ export default Ember.Component.extend({ }, attrSearch() { + this.sendAction('clearSearch'); + let attrVisible = !this.get('attrVisible'); if (attrVisible) { this.set('attrVisible', attrVisible); diff --git a/addon/components/layers/wfs-layer.js b/addon/components/layers/wfs-layer.js index 71aa198cf..79ca5b549 100644 --- a/addon/components/layers/wfs-layer.js +++ b/addon/components/layers/wfs-layer.js @@ -613,7 +613,7 @@ export default BaseVectorLayer.extend({ break; case 'date': let dateInfo = getDateFormatFromString(e.searchOptions.queryString); - let searchDate = moment.utc(e.searchOptions.queryString, dateInfo.dateFormat + dateInfo.timeFormat, true); + let searchDate = moment(e.searchOptions.queryString, dateInfo.dateFormat + dateInfo.timeFormat, true); if (dateInfo.dateFormat && searchDate.isValid()) { let [startInterval, endInterval] = createTimeInterval(searchDate, dateInfo.dateFormat); From b228e3d7ea7f51d779d97ea4cfb5c64e0024c042 Mon Sep 17 00:00:00 2001 From: DaryaNeko Date: Mon, 4 Mar 2024 17:44:55 +0500 Subject: [PATCH 31/33] =?UTF-8?q?=D0=A0=D0=B0=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=D0=B4=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B5=D0=B9=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B8=D0=B3=D0=BE=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/mixins/layer-label.js | 32 ++++++++++++++++++++++++-------- addon/styles/addon.less | 6 ++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 50a09b432..a2718c5c0 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -435,14 +435,21 @@ export default Ember.Mixin.create({ _createLabelForPolygon(text, layer, style, labelsLayerZoom) { let latlng = null; - let iconWidth = 10; + let iconWidth = 40; let iconHeight = 40; + + let labelSize = labelsLayerZoom.settings.size; + if (labelSize) { + iconWidth = labelSize[0]; + iconHeight = labelSize[1]; + } + let anchor = null; let html = ''; let label; let geojsonWriter = new jsts.io.GeoJSONWriter(); - let className = 'label'; + let className = 'label polygon'; let multi = labelsLayerZoom.settings.multi; let objJsts = layer.toJsts(L.CRS.EPSG4326); @@ -489,11 +496,18 @@ export default Ember.Mixin.create({ _polygonMultiLabel(layer, style, text, labelsLayerZoom) { let latlng = null; - let iconWidth = 10; + let iconWidth = 40; let iconHeight = 40; + + let labelSize = labelsLayerZoom.settings.size; + if (labelSize) { + iconWidth = labelSize[0]; + iconHeight = labelSize[1]; + } + let anchor = null; let html = ''; - let className = 'label'; + let className = 'label polygon multi'; let label; let geojsonWriter = new jsts.io.GeoJSONWriter(); let objJsts = layer.toJsts(L.CRS.EPSG4326); @@ -1271,13 +1285,15 @@ export default Ember.Mixin.create({ _labelsLayersCreate(leafletObject) { let labelsLayers = this.get('labelsLayers'); let leafletMap = this.get('leafletMap'); - let labelSettingsString = this.get('labelSettings.labelSettingsString'); + if (Ember.isNone(labelsLayers)) { let labelsLayersArray = Ember.A(); - if (labelSettingsString) { - this._createLabelsLayerOldSettings(labelsLayersArray); - } else { + + let rules = this.get('labelSettings.rules'); + if (!Ember.isNone(rules)) { this._createLabelsLayer(labelsLayersArray); + } else { + this._createLabelsLayerOldSettings(labelsLayersArray); } leafletObject.labelsLayers = labelsLayersArray; diff --git a/addon/styles/addon.less b/addon/styles/addon.less index 761e66bb5..efc6035b2 100644 --- a/addon/styles/addon.less +++ b/addon/styles/addon.less @@ -76,6 +76,12 @@ display: none !important; } +.leaflet-marker-icon.label.polygon { + display: flex; + justify-content: center; + flex-direction: column; +} + .leaflet-marker-icon.label.point { display: flex; From 5398fc9ee679f680c993e66eb7e131b5de299884 Mon Sep 17 00:00:00 2001 From: DaryaNeko Date: Mon, 4 Mar 2024 17:51:12 +0500 Subject: [PATCH 32/33] merge-151123-040324 --- addon/mixins/layer-label.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index c425d252c..aceff1526 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -467,7 +467,7 @@ export default Ember.Mixin.create({ html = '
' + text + '
'; let paneLabel = labelsLayerZoom._paneLabel; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); // возможно тут тоже надо будет сделать L.featureGroup() label = this._createLabelMarker(layer, optionsMarker, paneLabel); @@ -521,7 +521,7 @@ export default Ember.Mixin.create({ let centroidN = geojsonWriter.write(centroidNJsts); latlng = L.latLng(centroidN.coordinates[1], centroidN.coordinates[0]); html = '
' + text + '
'; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); let labelN = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); label.addLayer(labelN); } @@ -580,7 +580,7 @@ export default Ember.Mixin.create({ iconWidth = 12; iconHeight = 12; html = Ember.$(layer._svgConteiner).html(); - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); if (multi) { let labelN = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); @@ -599,7 +599,7 @@ export default Ember.Mixin.create({ iconHeight = 12; html = Ember.$(layer._svgConteiner).html(); - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); label = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); } } From b6e732ab479e51292162b82757399c1c9f6e6de4 Mon Sep 17 00:00:00 2001 From: DaryaNeko Date: Tue, 19 Mar 2024 14:56:25 +0500 Subject: [PATCH 33/33] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D1=8F=D0=BA=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=D0=BF=D0=B8=D1=81=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/components/layers/odata-vector-layer.js | 2 +- addon/components/layers/wfs-layer.js | 2 +- addon/styles/addon.less | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addon/components/layers/odata-vector-layer.js b/addon/components/layers/odata-vector-layer.js index d56ae0148..892b77777 100644 --- a/addon/components/layers/odata-vector-layer.js +++ b/addon/components/layers/odata-vector-layer.js @@ -209,7 +209,7 @@ export default BaseVectorLayer.extend({ }); }); - this._createStringLabel([layer], leafletObject.labelsLayers); + this._createStringLabel([layer], leafletObject); } }, diff --git a/addon/components/layers/wfs-layer.js b/addon/components/layers/wfs-layer.js index 79ca5b549..ce565e4a8 100644 --- a/addon/components/layers/wfs-layer.js +++ b/addon/components/layers/wfs-layer.js @@ -244,7 +244,7 @@ export default BaseVectorLayer.extend({ }); }); - this._createStringLabel([layer], leafletObject.labelsLayers); + this._createStringLabel([layer], leafletObject); } }, diff --git a/addon/styles/addon.less b/addon/styles/addon.less index efc6035b2..52096a346 100644 --- a/addon/styles/addon.less +++ b/addon/styles/addon.less @@ -80,6 +80,7 @@ display: flex; justify-content: center; flex-direction: column; + align-items: center; } .leaflet-marker-icon.label.point {