Fixed can't access property getUnits, sourceProj is null (#19275)

* Fixed can't access property getUnits, sourceProj is null
* Linted files
* moved the third party dependencies

Fixes the issue coming up upon entering an invalid SRID.
Now the function would execute only if the sourceProj is a valid object.

Fixes #19266

---------

Signed-off-by: Sachin Bahukhandi <sachinb0013@gmail.com>
This commit is contained in:
Sachin Bahukhandi 2024-09-18 21:19:27 +05:30 committed by GitHub
parent 38837dcf55
commit b96cc3a1ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import { Tile, Vector as VectorLayer } from 'ol/layer.js';
import { OSM, Vector as VectorSource } from 'ol/source.js';
import { Circle, Fill, Stroke, Style, Text } from 'ol/style.js';
import { Feature, Map, View } from 'ol';
import { get as getProjection } from 'ol/proj.js';
const ol = {
control: {
@ -29,7 +30,7 @@ const ol = {
style: {
Circle, Fill, Stroke, Style, Text
},
Feature, Map, View
Feature, Map, View, getProjection
};
export default ol;

View File

@ -527,10 +527,15 @@ function getFeaturesFromOpenLayersData (geometries: any[]): any[] {
}
if (geometry.geometry.srid !== 3857) {
olGeometry = olGeometry.transform(
'EPSG:' + (geometry.geometry.srid !== 0 ? geometry.geometry.srid : 4326),
'EPSG:3857'
);
const source = 'EPSG:' + (geometry.geometry.srid !== 0 ? geometry.geometry.srid : 4326);
const sourceProj = window.ol.getProjection(source);
if (sourceProj) {
olGeometry = olGeometry.transform(
source,
'EPSG:3857'
);
}
}
if (geometry.style.text) {