Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo Typescript migration #133

Merged
merged 20 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { WritableDeep } from 'type-fest';
import { useEffect, useRef } from 'react';
import { createTheme, StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
import { GeoData, NetworkMap, NetworkMapRef } from '../../src';
import { Equipment } from '../../src/components/network-map-viewer/network/map-equipments';
import { addNadToDemo, addSldToDemo } from './diagram-viewers/add-diagrams';
import DemoMapEquipments from './map-viewer/demo-map-equipments';
import { GeoData, type MapEquipment, MapEquipments, NetworkMap, type NetworkMapRef } from '../../src';

import sposdata from './map-viewer/data/spos.json';
import lposdata from './map-viewer/data/lpos.json';
import smapdata from './map-viewer/data/smap.json';
import lmapdata from './map-viewer/data/lmap.json';
import { addNadToDemo, addSldToDemo } from './diagram-viewers/add-diagrams';
import sposdata from './map-viewer/data/spos';
import lposdata from './map-viewer/data/lpos';
import smapdata from './map-viewer/data/smap';
import lmapdata from './map-viewer/data/lmap';

export default function App() {
const INITIAL_ZOOM = 9;
Expand All @@ -29,7 +28,7 @@ export default function App() {
}, []);

//called after a click (right mouse click) on an equipment (line or substation)
function showEquipmentMenu(equipment: Equipment, x: number, y: number, type: string) {
function showEquipmentMenu(equipment: MapEquipment, x: number, y: number, type: string) {
console.log('# Show equipment menu: ' + JSON.stringify(equipment) + ', type: ' + type);
}

Expand All @@ -55,10 +54,12 @@ export default function App() {

//declare data to be displayed: coordinates and network data
const geoData = new GeoData(new Map(), new Map());
geoData.setSubstationPositions(sposdata);
geoData.setLinePositions(lposdata);
geoData.setSubstationPositions(sposdata as WritableDeep<typeof sposdata>);
geoData.setLinePositions(lposdata as WritableDeep<typeof lposdata>);

const mapEquipments = new DemoMapEquipments(smapdata, lmapdata);
const mapEquipments = new MapEquipments();
mapEquipments.updateSubstations(smapdata as WritableDeep<typeof smapdata>, true);
mapEquipments.updateLines(lmapdata as WritableDeep<typeof lmapdata>, true);

useEffect(() => {
const handleContextmenu = (e: MouseEvent) => {
Expand Down
26 changes: 0 additions & 26 deletions demo/src/map-viewer/data/lmap.json

This file was deleted.

33 changes: 33 additions & 0 deletions demo/src/map-viewer/data/lmap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright © 2024, 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 default [
{
id: 'L1',
voltageLevelId1: 'VL2_3',
voltageLevelId2: 'VL1_1',
name: 'Line1',
terminal1Connected: true,
terminal2Connected: true,
p1: -115.0,
p2: 115.0,
i1: 290.0,
i2: 310.0,
},
{
id: 'L2',
voltageLevelId1: 'VL2_3',
voltageLevelId2: 'VL1_1',
name: 'Line2',
terminal1Connected: true,
terminal2Connected: true,
p1: -55.0,
p2: 55.0,
i1: 140.0,
i2: 155.0,
},
] as const;
32 changes: 0 additions & 32 deletions demo/src/map-viewer/data/lpos.json

This file was deleted.

39 changes: 39 additions & 0 deletions demo/src/map-viewer/data/lpos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright © 2024, 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 default [
{
id: 'L1',
coordinates: [
{
lat: 45.18608,
lon: 9.15484,
},
{
lat: 45.249375,
lon: 9.35453,
},
{
lat: 45.31267,
lon: 9.49322,
},
],
},
{
id: 'L2',
coordinates: [
{
lat: 45.18608,
lon: 9.15484,
},
{
lat: 45.31267,
lon: 9.49322,
},
],
},
] as const;
39 changes: 0 additions & 39 deletions demo/src/map-viewer/data/smap.json

This file was deleted.

46 changes: 46 additions & 0 deletions demo/src/map-viewer/data/smap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright © 2024, 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 default [
{
id: 'SUB1',
name: 'Substation1',
voltageLevels: [
{
id: 'VL1_1',
substationId: 'SUB1',
nominalV: 225.0,
},
{
id: 'VL1_2',
substationId: 'SUB1',
nominalV: 110.0,
},
],
},
{
id: 'SUB2',
name: 'Substation2',
voltageLevels: [
{
id: 'VL2_1',
substationId: 'SUB2',
nominalV: 110.0,
},
{
id: 'VL2_2',
substationId: 'SUB2',
nominalV: 380.0,
},
{
id: 'VL2_3',
substationId: 'SUB2',
nominalV: 225.0,
},
],
},
] as const;
16 changes: 0 additions & 16 deletions demo/src/map-viewer/data/spos.json

This file was deleted.

23 changes: 23 additions & 0 deletions demo/src/map-viewer/data/spos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright © 2024, 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 default [
{
id: 'SUB1',
coordinate: {
lat: 45.31267,
lon: 9.49322,
},
},
{
id: 'SUB2',
coordinate: {
lat: 45.18608,
lon: 9.15484,
},
},
] as const;
23 changes: 0 additions & 23 deletions demo/src/map-viewer/demo-map-equipments.ts

This file was deleted.

Loading
Loading