Skip to content

Commit

Permalink
Merge pull request #838 from Flexberry/rgis-develop
Browse files Browse the repository at this point in the history
Rgis develop
  • Loading branch information
DaryaNeko authored Mar 19, 2024
2 parents 1cf131b + d018581 commit 5f70c1e
Show file tree
Hide file tree
Showing 40 changed files with 807 additions and 380 deletions.
27 changes: 27 additions & 0 deletions addon/components/base-vector-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
12 changes: 2 additions & 10 deletions addon/components/feature-result-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://emberjs.com/api/classes/Ember.Component.html">Ember.Component</a>
*/
export default Ember.Component.extend(ResultFeatureInitializer, {
export default Ember.Component.extend(SlotsMixin, ResultFeatureInitializer, {

/**
Service for managing map API.
Expand Down Expand Up @@ -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.
Expand Down
91 changes: 10 additions & 81 deletions addon/components/flexberry-edit-layer-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -778,8 +777,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);
Expand Down Expand Up @@ -893,81 +894,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) {
Expand Down Expand Up @@ -1172,8 +1098,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
Expand Down Expand Up @@ -1248,8 +1176,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);
}

Expand Down
82 changes: 51 additions & 31 deletions addon/components/flexberry-identify-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'Файл не содержит геометрических объектов',

Expand All @@ -42,11 +57,10 @@ export default Ember.Component.extend(CheckFileMixin, {

typeGeometryErrorMessage: 'Указанный тип геометрии противоречит объектам в файле',

warningMessageSRS: 'Укажите верную систему координат, указанную в загружаемом файле. ' +
'При выборе ошибочной системы координат слой может некорректно отображаться на карте',

warningMessageEmptyGeometry: 'В файле обнаружены объекты без геометрии. Дальнейшая загрузка будет осуществлена без них',

warningMessageAutoCRS: 'У загруженного файла не определена система координат. Выберите систему координат из списка',

emptyGeometryField: 'Укажите название поля с геометрией в файле (WKT/X,Y)',

/**
Expand All @@ -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');
},
Expand Down Expand Up @@ -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');
Expand All @@ -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();
Expand All @@ -154,36 +161,35 @@ 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() {
this.set('file', null);
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);
Expand All @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions addon/components/flexberry-layers-attributes-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions addon/components/flexberry-search-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -275,6 +277,8 @@ export default Ember.Component.extend({
},

attrSearch() {
this.sendAction('clearSearch');

let attrVisible = !this.get('attrVisible');
if (attrVisible) {
this.set('attrVisible', attrVisible);
Expand Down
Loading

0 comments on commit 5f70c1e

Please sign in to comment.