Skip to content

Commit

Permalink
Delete file: src/utils/ol/index.js (#542)
Browse files Browse the repository at this point in the history
* Extract utils and delete file: `src/utils/parsers/index.js`

* Clean code

* Clean code

---------

Co-authored-by: volterra79 <[email protected]>
  • Loading branch information
Raruto and volterra79 authored Jan 18, 2024
1 parent ca3889a commit 54ad5a5
Show file tree
Hide file tree
Showing 35 changed files with 429 additions and 319 deletions.
41 changes: 39 additions & 2 deletions src/app/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ import GUI from 'services/gui';
//MIXINS
import Mixins from 'mixins';

import { reverseGeometry } from 'utils/reverseGeometry';
import { getExtentForViewAndSize } from 'utils/getExtentForViewAndSize';
import { createPolygonLayerFromBBox } from 'utils/createPolygonLayerFromBBox';
import { getLengthMessageText } from 'utils/getLengthMessageText';
import { needUseSphereMethods } from 'utils/needUseSphereMethods';
import { transformMeterLength } from 'utils/transformMeterLength';
import { createMeasureTooltip } from 'utils/createMeasureTooltip';
import { formatMeasure } from 'utils/formatMeasure';
import { getCurrentMapUnit } from 'utils/getCurrentMapUnit';
import { getAreaMessageText } from 'utils/getAreaMessageText';
import { transformMeterArea } from 'utils/transformMeterArea';
import { removeMeasureTooltip } from 'utils/removeMeasureTooltip';
import { setMeasureTooltipStatic } from 'utils/setMeasureTooltipStatic';
import { getMetersFromDegrees } from 'utils/getMetersFromDegrees';
import { getDPI } from 'utils/getDPI';
import { getResolutionFromScale } from 'utils/getResolutionFromScale';
import { getScaleFromResolution } from 'utils/getScaleFromResolution';
import { mergeOptions } from 'utils/mergeOptions';

const G3WObject = require('core/g3wobject');
const utils = require('utils');
const geoutils = require('utils/geo');
Expand Down Expand Up @@ -96,7 +115,6 @@ const PickCoordinatesInteraction = require('g3w-ol/interactions/pickcoordinatesi
const DeleteFeatureInteraction = require('g3w-ol/interactions/deletefeatureinteraction');
const AreaInteraction = require('g3w-ol/interactions/areainteraction');
const LengthInteraction = require('g3w-ol/interactions/lengthinteraction');
const g3wolutils = require('utils/ol');

module.exports = {

Expand Down Expand Up @@ -250,7 +268,26 @@ module.exports = {
}
},
controls: {},
utils: g3wolutils
utils: {
merge: mergeOptions,
getExtentForViewAndSize,
createPolygonLayerFromBBox,
reverseGeometry,
getScaleFromResolution,
getResolutionFromScale,
getDPI,
getMetersFromDegrees,
needUseSphereMethods,
getLengthMessageText,
getAreaMessageText,
formatMeasure,
createMeasureTooltip,
getCurrentMapUnit,
transformMeterLength,
transformMeterArea,
removeMeasureTooltip,
setMeasureTooltipStatic,
},
},

// G3W-SUITE debug info
Expand Down
19 changes: 19 additions & 0 deletions src/app/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,36 @@ export const LOGO_GIS3W = 'images/logo_gis3w_156_85.png';
*/
export const SPATIAL_METHODS = ['intersects', 'within'];

/**
* DPI96
*
* DOTS_PER_INCH = ol.has.DEVICE_PIXEL_RATIO * 96;
*
* @since 3.10.0
*/
export const DOTS_PER_INCH = 96;

/**
* @since 3.10.0
*/
export const INCHES_PER_UNIT = {
m: 39.37,
degrees: 4374754
};

export default {
APP_VERSION,
API_BASE_URLS,
DEFAULT_EDITING_CAPABILITIES,
DOTS_PER_INCH,
DOWNLOAD_FORMATS,
FILTER_OPERATORS,
FILTER_EXPRESSION_OPERATORS,
FONT_AWESOME_ICONS,
G3W_FID,
GEOMETRY_FIELDS,
GEOMETRY_TYPES,
INCHES_PER_UNIT,
LIST_OF_RELATIONS_TITLE,
LIST_OF_RELATIONS_ID,
LOCAL_ITEM_IDS,
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/layers/mixins/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* @since 3.9.0
*/

import GUI from 'services/gui';
import ApplicationService from 'services/application';
import GUI from 'services/gui';
import ApplicationService from 'services/application';
import { getScaleFromResolution } from 'utils/getScaleFromResolution';

const Projections = require('g3w-ol/projection/projections');
const { getScaleFromResolution } = require('utils/ol');
const { createFeatureFromFeatureObject } = require('utils/geo');
const { XHR, sanitizeUrl } = require('utils');

Expand Down
7 changes: 4 additions & 3 deletions src/app/core/layers/providersfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import ApplicationState from 'store/application-state';
import RelationsService from 'services/relations';
import { QUERY_POINT_TOLERANCE } from 'constant';
import { QgsFilterToken } from 'core/layers/utils/QgsFilterToken';
import { getDPI } from 'utils/getDPI';
import { getExtentForViewAndSize } from 'utils/getExtentForViewAndSize';
import { get_legend_params } from 'utils/get_legend_params';

const G3WObject = require('core/g3wobject');
Expand All @@ -15,12 +17,11 @@ const { handleQueryResponse } = require('utils/geo');
const Parsers = require('utils/parsers');
const { t } = require('core/i18n/i18n.service');
const Feature = require('core/layers/features/feature');
const geoutils = require('utils/ol');
const Filter = require('core/layers/filter/filter');


const GETFEATUREINFO_IMAGE_SIZE = [101, 101];
const DPI = geoutils.getDPI();
const DPI = getDPI();

const is_defined = d => undefined !== d;

Expand Down Expand Up @@ -505,7 +506,7 @@ const Providers = {
? layers.map(layer => layer.getWMSInfoLayerName()).join(',')
: this._layer.getWMSInfoLayerName();

const extent = geoutils.getExtentForViewAndSize(coordinates, resolution, 0, size);
const extent = getExtentForViewAndSize(coordinates, resolution, 0, size);

const is_map_tolerance = ('map' === query_point_tolerance.unit);

Expand Down
5 changes: 3 additions & 2 deletions src/app/g3w-ol/controls/areacontrol.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const utils = require('utils/ol');
import { mergeOptions } from 'utils/mergeOptions';

const AreaIteraction = require('g3w-ol/interactions/areainteraction');
const MeasureControl = require('g3w-ol/controls/measurecontrol');

Expand All @@ -9,7 +10,7 @@ const AreaControl = function(options={}) {
clickmap: true, // set ClickMap
interactionClass: AreaIteraction
};
options = utils.merge(options, _options);
options = mergeOptions(options, _options);
MeasureControl.call(this, options);
};

Expand Down
4 changes: 2 additions & 2 deletions src/app/g3w-ol/controls/basequerypolygoncontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* @since v3.8
*/
import { SPATIAL_METHODS } from 'app/constant';
import { mergeOptions } from 'utils/mergeOptions';

const InteractionControl = require('g3w-ol/controls/interactioncontrol');
const { merge } = require('utils/ol');
const { Geometry } = require('utils/geo');

const VALIDGEOMETRIES = Geometry.getAllPolygonGeometryTypes();
Expand All @@ -32,7 +32,7 @@ const BaseQueryPolygonControl = function(options = {}) {
onhover: true
};

options = merge(options, default_options);
options = mergeOptions(options, default_options);

options.geometryTypes = VALIDGEOMETRIES;

Expand Down
7 changes: 4 additions & 3 deletions src/app/g3w-ol/controls/lengthcontrol.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const utils = require('utils/ol');
import { mergeOptions } from 'utils/mergeOptions';

const LenghtIteraction = require('g3w-ol/interactions/lengthinteraction');
const MeasureControl = require('g3w-ol/controls/measurecontrol');
const MeasureControl = require('g3w-ol/controls/measurecontrol');

const LengthControl = function(options={}) {
const _options = {
Expand All @@ -10,7 +11,7 @@ const LengthControl = function(options={}) {
interactionClass: LenghtIteraction
};

options = utils.merge(options,_options);
options = mergeOptions(options,_options);
MeasureControl.call(this, options);
};

Expand Down
8 changes: 4 additions & 4 deletions src/app/g3w-ol/controls/querycontrol.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import GUI from 'services/gui';
import ProjectsRegistry from 'store/projects';
import GUI from 'services/gui';
import ProjectsRegistry from 'store/projects';
import DataRouterService from 'services/data';
import { mergeOptions } from 'utils/mergeOptions';

const { throttle } = require('utils');
const utils = require('utils/ol');
const InteractionControl = require('g3w-ol/controls/interactioncontrol');
const PickCoordinatesInteraction = require('g3w-ol/interactions/pickcoordinatesinteraction');

Expand All @@ -17,7 +17,7 @@ const QueryControl = function(options = {}){
interactionClass: PickCoordinatesInteraction,
};

options = utils.merge(options, _options);
options = mergeOptions(options, _options);

InteractionControl.call(this, options);
};
Expand Down
5 changes: 3 additions & 2 deletions src/app/g3w-ol/controls/resetcontrol.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const utils = require('utils/ol');
import { mergeOptions } from 'utils/mergeOptions';

const InteractionControl = require('g3w-ol/controls/interactioncontrol');

const ResetControl = function(options){
Expand All @@ -9,7 +10,7 @@ const ResetControl = function(options){
tipLabel: "Pan",
label: "\ue901"
};
options = utils.merge(options,_options);
options = mergeOptions(options,_options);
InteractionControl.call(this,options);
};

Expand Down
8 changes: 5 additions & 3 deletions src/app/g3w-ol/controls/scalecontrol.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const {t} = require('core/i18n/i18n.service');
const { getResolutionFromScale, getScaleFromResolution } = require('utils/ol');
import { PRINT_SCALES } from 'app/constant';
import { PRINT_SCALES } from 'app/constant';
import { getResolutionFromScale } from 'utils/getResolutionFromScale';
import { getScaleFromResolution } from 'utils/getScaleFromResolution';

const { t } = require('core/i18n/i18n.service');

const ScaleControl = function(options= {}) {
this.isMobile = options.isMobile || false;
Expand Down
12 changes: 6 additions & 6 deletions src/app/g3w-ol/controls/streetviewcontrol.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ApplicationState from 'store/application-state';
import GUI from 'services/gui';
import GUI from 'services/gui';
import { mergeOptions } from 'utils/mergeOptions';

const { XHR } = require('utils');
const utils = require('utils/ol');
const StreetViewComponent = require('gui/streetview/vue/streetview');
const InteractionControl = require('g3w-ol/controls/interactioncontrol');
const { XHR } = require('utils');
const StreetViewComponent = require('gui/streetview/vue/streetview');
const InteractionControl = require('g3w-ol/controls/interactioncontrol');
const PickCoordinatesInteraction = require('g3w-ol/interactions/pickcoordinatesinteraction');

const GoogleStreetViewApiUrl = `https://maps.googleapis.com/maps/api/`;
Expand Down Expand Up @@ -73,7 +73,7 @@ const StreetViewControl = function(options={}) {
}
});

options = utils.merge(options,_options);
options = mergeOptions(options, _options);

InteractionControl.call(this,options);
};
Expand Down
13 changes: 6 additions & 7 deletions src/app/g3w-ol/interactions/measureinteraction.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { t } = require('core/i18n/i18n.service');
const {
createMeasureTooltip,
setMeasureTooltipStatic,
removeMeasureTooltip,
needUseSphereMethods
} = require('utils/ol');
import { createMeasureTooltip } from 'utils/createMeasureTooltip';
import { setMeasureTooltipStatic } from 'utils/setMeasureTooltipStatic';
import { removeMeasureTooltip } from 'utils/removeMeasureTooltip';
import { needUseSphereMethods } from 'utils/needUseSphereMethods';

const { t } = require('core/i18n/i18n.service');

const MeasureIteraction = function(options={}) {
this._helpTooltip;
Expand Down
4 changes: 3 additions & 1 deletion src/app/g3w-ol/layers/rasters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const DPI = require('utils/ol').getDPI();
import { getDPI } from 'utils/getDPI';

const DPI = getDPI();

const RasterLayers = {};

Expand Down
24 changes: 11 additions & 13 deletions src/app/gui/map/mapservice.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { MAP_SETTINGS } from 'app/constant';
import DataRouterService from 'services/data';
import MapLayersStoresRegistry from 'store/map-layers';
import ProjectsRegistry from 'store/projects';
import ApplicationService from 'services/application';
import ControlsRegistry from 'store/map-controls';
import GUI from 'services/gui';
import MapControlZoomHistory from "components/MapControlZoomHistory.vue";
import MapControlGeocoding from 'components/MapControlGeocoding.vue';
import { MAP_SETTINGS } from 'app/constant';
import DataRouterService from 'services/data';
import MapLayersStoresRegistry from 'store/map-layers';
import ProjectsRegistry from 'store/projects';
import ApplicationService from 'services/application';
import ControlsRegistry from 'store/map-controls';
import GUI from 'services/gui';
import MapControlZoomHistory from "components/MapControlZoomHistory.vue";
import MapControlGeocoding from 'components/MapControlGeocoding.vue';
import { getScaleFromResolution } from 'utils/getScaleFromResolution';
import { getResolutionFromScale } from 'utils/getResolutionFromScale';

const {
inherit,
Expand All @@ -26,10 +28,6 @@ const {
getGeoTIFFfromServer,
} = require('utils/geo');
const BaseLayers = require('g3w-ol/layers/bases');
const {
getScaleFromResolution,
getResolutionFromScale
} = require('utils/ol');
const VectorLayer = require('core/layers/vectorlayer');

const Control = require('g3w-ol/controls/control');
Expand Down
19 changes: 9 additions & 10 deletions src/app/gui/print/printservice.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ProjectsRegistry from 'store/projects';
import ApplicationService from 'services/application';
import ApplicationState from 'store/application-state';
import ProjectsRegistry from 'store/projects';
import ApplicationService from 'services/application';
import ApplicationState from 'store/application-state';
import {
PRINT_SCALES as scale,
PRINT_RESOLUTIONS as dpis,
PRINT_FORMATS as formats
} from 'app/constant';
import GUI from 'services/gui';
} from 'app/constant';
import GUI from 'services/gui';
import { getScaleFromResolution } from 'utils/getScaleFromResolution';
import { getResolutionFromScale } from 'utils/getResolutionFromScale';
import { getMetersFromDegrees } from 'utils/getMetersFromDegrees';


const {
base,
Expand All @@ -16,11 +20,6 @@ const {
} = require('utils');
const { t } = require('core/i18n/i18n.service');
const G3WObject = require('core/g3wobject');
const {
getScaleFromResolution,
getResolutionFromScale,
getMetersFromDegrees
} = require('utils/ol');
const PrintPage = require('gui/print/vue/printpage');

/*
Expand Down
Loading

0 comments on commit 54ad5a5

Please sign in to comment.