Skip to content

Commit

Permalink
fix: make equipmentMap more generic
Browse files Browse the repository at this point in the history
Signed-off-by: LE SAULNIER Kevin <[email protected]>
  • Loading branch information
LE SAULNIER Kevin committed Feb 13, 2024
1 parent 8aa1ac2 commit 167acac
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 288 deletions.
4 changes: 2 additions & 2 deletions demo/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
StyledEngineProvider,
} from '@mui/material/styles';

import MapEquipments from './map-viewer/map-equipments';
import DemoMapEquipments from './map-viewer/map-equipments';

import sposdata from './map-viewer/data/spos.json';
import lposdata from './map-viewer/data/lpos.json';
Expand Down Expand Up @@ -68,7 +68,7 @@ function App() {
geoData.setSubstationPositions(sposdata);
geoData.setLinePositions(lposdata);

const mapEquipments = new MapEquipments(smapdata, lmapdata);
const mapEquipments = new DemoMapEquipments(smapdata, lmapdata);

useEffect(() => {
const handleContextmenu = (e) => {
Expand Down
4 changes: 2 additions & 2 deletions demo/src/map-viewer/map-equipments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { MapEquipmentsBase } from '../../../src';
export default class MapEquipments extends MapEquipmentsBase {
import { MapEquipments } from '../../../src';
export default class DemoMapEquipments extends MapEquipments {
initEquipments(smapdata, lmapdata) {
this.updateSubstations(smapdata, true);
this.updateLines(lmapdata, true);
Expand Down
281 changes: 0 additions & 281 deletions src/components/network-map-viewer/network/map-equipments-base.js

This file was deleted.

68 changes: 68 additions & 0 deletions src/components/network-map-viewer/network/map-equipments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Copyright (c) 2022, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

export class MapEquipments {
substations = [];

substationsById = new Map();

lines = [];

linesById = new Map();

hvdcLines = [];

hvdcLinesById = new Map();

voltageLevels = [];

voltageLevelsById = new Map();

nominalVoltages = [];

intlRef = undefined;

constructor() {
// dummy constructor, to make children classes constructors happy
}

getVoltageLevels() {
return this.voltageLevels;
}

getVoltageLevel(id) {
return this.voltageLevelsById.get(id);
}

getSubstations() {
return this.substations;
}

getSubstation(id) {
return this.substationsById.get(id);
}

getNominalVoltages() {
return this.nominalVoltages;
}

getLines() {
return this.lines;
}

getLine(id) {
return this.linesById.get(id);
}

getHvdcLines() {
return this.hvdcLines;
}

getHvdcLine(id) {
return this.hvdcLinesById.get(id);
}
}
4 changes: 2 additions & 2 deletions src/components/network-map-viewer/network/network-map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { SubstationLayer } from './substation-layer';
import { getNominalVoltageColor } from '../../../utils/colors';
import { RunningStatus } from '../utils/running-status';
import { Button, useTheme } from '@mui/material';
import { MapEquipmentsBase } from './map-equipments-base';
import { MapEquipments } from './map-equipments';
import { useNameOrId } from '../utils/equipmentInfosHandler';
import { Map, NavigationControl, useControl } from 'react-map-gl';
import { MapboxOverlay } from '@deck.gl/mapbox';
Expand Down Expand Up @@ -535,7 +535,7 @@ NetworkMap.defaultProps = {
};

NetworkMap.propTypes = {
mapEquipments: PropTypes.instanceOf(MapEquipmentsBase),
mapEquipments: PropTypes.instanceOf(MapEquipments),
geoData: PropTypes.instanceOf(GeoData),
filteredNominalVoltages: PropTypes.array,
labelsZoomThreshold: PropTypes.number.isRequired,
Expand Down
Loading

0 comments on commit 167acac

Please sign in to comment.