Skip to content

Commit 23c32ca

Browse files
Remove unused depencies (vis, modern-normalize, prop-types, geolib) and unused code (map ruler / labels) (#1026)
1 parent 375df9d commit 23c32ca

File tree

12 files changed

+20
-994
lines changed

12 files changed

+20
-994
lines changed

ui-frontend/packages/catalog-ui-search/package.json

-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
"focus-visible": "5.1.0",
102102
"font-awesome": "4.7",
103103
"geo-convex-hull": "1.2.0",
104-
"geolib": "^3.2.1",
105104
"geospatialdraw": "0.4.17",
106105
"golden-layout": "1.5.9",
107106
"immer.1.5.0": "https://registry.npmjs.org/immer/-/immer-1.5.0.tgz",
@@ -111,15 +110,13 @@
111110
"lodash.debounce": "4.0.8",
112111
"lodash.get": "4.4.2",
113112
"lodash.isequalwith": "4.4.0",
114-
"modern-normalize": "1.1.0",
115113
"moment": "2.30.1",
116114
"moment-timezone": "0.5.46",
117115
"mt-geo": "1.0.1",
118116
"ol": "10.2.1",
119117
"plotly.js": "2.35.3",
120118
"polished": "4.3.1",
121119
"postcss-focus-visible": "8.0.2",
122-
"prop-types": "15.7.2",
123120
"query-string": "6.13.1",
124121
"re-resizable": "6.1.0",
125122
"react": "18.3.1",
@@ -141,7 +138,6 @@
141138
"use-resize-observer": "6.1.0",
142139
"usng.js": "0.4.5",
143140
"uuid": "9.0.0",
144-
"vis": "4.15.0",
145141
"wkx": "0.4.5"
146142
},
147143
"resolutions": {

ui-frontend/packages/catalog-ui-search/src/main/webapp/component/visualization/maps/cesium/map.cesium.ts

+1-201
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ import { StartupDataStore } from '../../../../js/model/Startup/startup'
3131
const defaultColor = '#3c6dd5'
3232
const eyeOffset = new Cesium.Cartesian3(0, 0, 0)
3333
const pixelOffset = new Cesium.Cartesian2(0.0, 0)
34-
const rulerColor = new Cesium.Color(0.31, 0.43, 0.52)
35-
const rulerPointColor = '#506f85'
36-
const rulerLineHeight = 0
3734
Cesium.BingMapsApi.defaultKey = StartupDataStore.Configuration.getBingKey() || 0
3835
const imageryProviderTypes = CesiumImageryProviderTypes
3936
function setupTerrainProvider(viewer: any, terrainProvider: any) {
@@ -192,7 +189,6 @@ export default function CesiumMap(
192189
const drawHelper = new (DrawHelper as any)(map)
193190
map.drawHelper = drawHelper
194191
const billboardCollection = setupBillboardCollection()
195-
const labelCollection = setupLabelCollection()
196192
setupTooltip(map, selectionInterface)
197193
function updateCoordinatesTooltip(position: any) {
198194
const cartesian = map.camera.pickEllipsoid(
@@ -225,74 +221,6 @@ export default function CesiumMap(
225221
map.scene.primitives.add(billboardCollection)
226222
return billboardCollection
227223
}
228-
function setupLabelCollection() {
229-
const labelCollection = new Cesium.LabelCollection()
230-
map.scene.primitives.add(labelCollection)
231-
return labelCollection
232-
}
233-
/*
234-
* Returns a visible label that is in the same location as the provided label (geometryInstance) if one exists.
235-
* If findSelected is true, the function will also check for hidden labels in the same location but are selected.
236-
*/
237-
function findOverlappingLabel(findSelected: any, geometry: any) {
238-
return _.find(
239-
mapModel.get('labels'),
240-
(label) =>
241-
label.position.x === geometry.position.x &&
242-
label.position.y === geometry.position.y &&
243-
((findSelected && label.isSelected) || label.show)
244-
)
245-
}
246-
/*
247-
Only shows one label if there are multiple labels in the same location.
248-
249-
Show the label in the following importance:
250-
- it is selected and the existing label is not
251-
- there is no other label displayed at the same location
252-
- it is the label that was found by findOverlappingLabel
253-
254-
Arguments are:
255-
- the label to show/hide
256-
- if the label is selected
257-
- if the search for overlapping label should include hidden selected labels
258-
*/
259-
function showHideLabel({ geometry, findSelected = false }: any) {
260-
const isSelected = geometry.isSelected
261-
const labelWithSamePosition = findOverlappingLabel(findSelected, geometry)
262-
if (
263-
isSelected &&
264-
labelWithSamePosition &&
265-
!labelWithSamePosition.isSelected
266-
) {
267-
labelWithSamePosition.show = false
268-
}
269-
const otherLabelNotSelected = labelWithSamePosition
270-
? !labelWithSamePosition.isSelected
271-
: true
272-
geometry.show =
273-
(isSelected && otherLabelNotSelected) ||
274-
!labelWithSamePosition ||
275-
geometry.id === labelWithSamePosition.id
276-
}
277-
/*
278-
Shows a hidden label. Used when deleting a label that is shown.
279-
*/
280-
function showHiddenLabel(geometry: any) {
281-
if (!geometry.show) {
282-
return
283-
}
284-
const hiddenLabel = _.find(
285-
mapModel.get('labels'),
286-
(label) =>
287-
label.position.x === geometry.position.x &&
288-
label.position.y === geometry.position.y &&
289-
label.id !== geometry.id &&
290-
!label.show
291-
)
292-
if (hiddenLabel) {
293-
hiddenLabel.show = true
294-
}
295-
}
296224

297225
const minimumHeightAboveTerrain = 2
298226
const exposedMethods = {
@@ -713,81 +641,6 @@ export default function CesiumMap(
713641
}
714642
})
715643
},
716-
/*
717-
* Draws a marker on the map designating a start/end point for the ruler measurement. The given
718-
* coordinates should be an object with 'lat' and 'lon' keys with degrees values. The given
719-
* marker label should be a single character or digit that is displayed on the map marker.
720-
*/
721-
addRulerPoint(coordinates: any) {
722-
const { lat, lon } = coordinates
723-
// a point requires an altitude value so just use 0
724-
const point = [lon, lat, 0]
725-
const options = {
726-
id: ' ',
727-
title: `Selected ruler coordinate`,
728-
image: DrawingUtility.getCircle({
729-
fillColor: rulerPointColor,
730-
icon: null,
731-
}),
732-
view: this,
733-
}
734-
return this.addPoint(point, options)
735-
},
736-
/*
737-
* Removes the given Billboard from the map.
738-
*/
739-
removeRulerPoint(billboardRef: any) {
740-
billboardCollection.remove(billboardRef)
741-
map.scene.requestRender()
742-
},
743-
/*
744-
* Draws a line on the map between the points in the given array of points.
745-
*/
746-
addRulerLine(point: any) {
747-
let startingCoordinates = mapModel.get('startingCoordinates')
748-
// creates an array of Cartesian3 points
749-
// a PolylineGeometry allows the line to follow the curvature of the surface
750-
map.coordArray = [
751-
startingCoordinates['lon'],
752-
startingCoordinates['lat'],
753-
rulerLineHeight,
754-
point['lon'],
755-
point['lat'],
756-
rulerLineHeight,
757-
]
758-
return map.entities.add({
759-
polyline: {
760-
positions: new Cesium.CallbackProperty(function () {
761-
return Cesium.Cartesian3.fromDegreesArrayHeights(map.coordArray)
762-
}, false),
763-
width: 5,
764-
show: true,
765-
material: rulerColor,
766-
},
767-
})
768-
},
769-
/*
770-
* Update the position of the ruler line
771-
*/
772-
setRulerLine(point: any) {
773-
let startingCoordinates = mapModel.get('startingCoordinates')
774-
map.coordArray = [
775-
startingCoordinates['lon'],
776-
startingCoordinates['lat'],
777-
rulerLineHeight,
778-
point['lon'],
779-
point['lat'],
780-
rulerLineHeight,
781-
]
782-
map.scene.requestRender()
783-
},
784-
/*
785-
* Removes the given polyline entity from the map.
786-
*/
787-
removeRulerLine(polyline: any) {
788-
map.entities.remove(polyline)
789-
map.scene.requestRender()
790-
},
791644
/*
792645
Adds a billboard point utilizing the passed in point and options.
793646
Options are a view to relate to, and an id, and a color.
@@ -914,41 +767,6 @@ export default function CesiumMap(
914767
map.scene.requestRender()
915768
return billboardRef
916769
},
917-
/*
918-
Adds a label utilizing the passed in point and options.
919-
Options are a view to an id and text.
920-
*/
921-
addLabel(point: any, options: any) {
922-
const pointObject = convertPointCoordinate(point)
923-
const cartographicPosition = Cesium.Cartographic.fromDegrees(
924-
pointObject.longitude,
925-
pointObject.latitude,
926-
pointObject.altitude
927-
)
928-
const cartesianPosition =
929-
map.scene.globe.ellipsoid.cartographicToCartesian(cartographicPosition)
930-
// X, Y offset values for the label
931-
const offset = new Cesium.Cartesian2(20, -15)
932-
// Cesium measurement for determining how to render the size of the label based on zoom
933-
const scaleZoom = new Cesium.NearFarScalar(1.5e4, 1.0, 8.0e6, 0.0)
934-
// Cesium measurement for determining how to render the translucency of the label based on zoom
935-
const translucencyZoom = new Cesium.NearFarScalar(1.5e6, 1.0, 8.0e6, 0.0)
936-
const labelRef = labelCollection.add({
937-
text: options.text,
938-
position: cartesianPosition,
939-
id: options.id,
940-
pixelOffset: offset,
941-
scale: 1.0,
942-
scaleByDistance: scaleZoom,
943-
translucencyByDistance: translucencyZoom,
944-
fillColor: Cesium.Color.BLACK,
945-
outlineColor: Cesium.Color.WHITE,
946-
outlineWidth: 10,
947-
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
948-
})
949-
mapModel.addLabel(labelRef)
950-
return labelRef
951-
},
952770
/*
953771
Adds a polyline utilizing the passed in line and options.
954772
Options are a view to relate to, and an id, and a color.
@@ -1136,11 +954,6 @@ export default function CesiumMap(
1136954
0,
1137955
options.isSelected ? -1 : 0
1138956
)
1139-
} else if (geometry.constructor === Cesium.Label) {
1140-
geometry.isSelected = options.isSelected
1141-
showHideLabel({
1142-
geometry,
1143-
})
1144957
} else if (geometry.constructor === Cesium.PolylineCollection) {
1145958
geometry._polylines.forEach((polyline: any) => {
1146959
polyline.material = options.isSelected
@@ -1158,10 +971,7 @@ export default function CesiumMap(
1158971
Updates a passed in geometry to be hidden
1159972
*/
1160973
hideGeometry(geometry: any) {
1161-
if (
1162-
geometry.constructor === Cesium.Billboard ||
1163-
geometry.constructor === Cesium.Label
1164-
) {
974+
if (geometry.constructor === Cesium.Billboard) {
1165975
geometry.show = false
1166976
} else if (geometry.constructor === Cesium.PolylineCollection) {
1167977
geometry._polylines.forEach((polyline: any) => {
@@ -1175,11 +985,6 @@ export default function CesiumMap(
1175985
showGeometry(geometry: any) {
1176986
if (geometry.constructor === Cesium.Billboard) {
1177987
geometry.show = true
1178-
} else if (geometry.constructor === Cesium.Label) {
1179-
showHideLabel({
1180-
geometry,
1181-
findSelected: true,
1182-
})
1183988
} else if (geometry.constructor === Cesium.PolylineCollection) {
1184989
geometry._polylines.forEach((polyline: any) => {
1185990
polyline.show = true
@@ -1189,16 +994,11 @@ export default function CesiumMap(
1189994
},
1190995
removeGeometry(geometry: any) {
1191996
billboardCollection.remove(geometry)
1192-
labelCollection.remove(geometry)
1193997
map.scene.primitives.remove(geometry)
1194998
//unminified cesium chokes if you feed a geometry with id as an Array
1195999
if (geometry.constructor === Cesium.Entity) {
11961000
map.entities.remove(geometry)
11971001
}
1198-
if (geometry.constructor === Cesium.Label) {
1199-
mapModel.removeLabel(geometry)
1200-
showHiddenLabel(geometry)
1201-
}
12021002
map.scene.requestRender()
12031003
},
12041004
destroyShapes() {

ui-frontend/packages/catalog-ui-search/src/main/webapp/component/visualization/maps/map.model.ts

-90
Original file line numberDiff line numberDiff line change
@@ -37,96 +37,6 @@ export default Backbone.AssociatedModel.extend({
3737
},
3838
target: undefined,
3939
targetMetacard: undefined,
40-
measurementState: 'NONE',
41-
currentDistance: 0,
42-
points: [],
43-
labels: [],
44-
line: undefined,
45-
distanceInfo: {
46-
left: 0,
47-
top: 0,
48-
},
49-
startingCoordinates: undefined,
50-
},
51-
/*
52-
* Sets the measurement state to the given new state.
53-
* Valid measurement states are:
54-
* - NONE
55-
* - START
56-
* - END
57-
*/
58-
changeMeasurementState(state: any) {
59-
// the current distance should be 0 when in the NONE or START state
60-
if (state === 'NONE' || state === 'START') {
61-
this.set({
62-
measurementState: state,
63-
currentDistance: 0,
64-
})
65-
} else {
66-
this.set({ measurementState: state })
67-
}
68-
},
69-
/*
70-
* Appends the given point to the array of points being tracked.
71-
*/
72-
addPoint(point: any) {
73-
this.set({
74-
points: [...this.get('points'), point],
75-
})
76-
},
77-
addLabel(label: any) {
78-
this.set({
79-
labels: [...this.get('labels'), label],
80-
})
81-
},
82-
removeLabel(label: any) {
83-
_.remove(this.get('labels'), (e) => e === label)
84-
},
85-
/*
86-
* Sets the line to the given new line. This represents the line on the map
87-
* being used for the ruler measurement.
88-
*/
89-
setLine(line: any) {
90-
this.set({ line })
91-
},
92-
/*
93-
* Resets the model's line and returns the old one.
94-
*/
95-
removeLine() {
96-
const line = this.get('line')
97-
this.set({ line: undefined })
98-
99-
return line
100-
},
101-
/*
102-
* Resets the model's array of points.
103-
*/
104-
clearPoints() {
105-
this.set({ points: [] })
106-
},
107-
/*
108-
* Set coordinates of the ruler measurements starting point
109-
*/
110-
setStartingCoordinates(coordinates: any) {
111-
this.set({ startingCoordinates: coordinates })
112-
},
113-
/*
114-
* Sets the current distance to the new given distance (in meters).
115-
*/
116-
setCurrentDistance(distance: any) {
117-
this.set({ currentDistance: distance })
118-
},
119-
addDistanceInfo(distanceInfo: any) {
120-
this.set({ distanceInfo })
121-
},
122-
/*
123-
* set the position of DistanceInfo in px relative to the top left of the Cesium component
124-
*/
125-
setDistanceInfoPosition(left: any, top: any) {
126-
this.set({ distanceInfo: { left, top } })
127-
},
128-
isOffMap() {
129-
return this.get('mouseLat') === undefined
13040
},
13141
clearMouseCoordinates() {
13242
this.set({

0 commit comments

Comments
 (0)