@@ -73,7 +73,7 @@ const countyloaddata = getCountyNodes(data);
7373data = countyloaddata . updatedata ;
7474
7575
76- var flowdata = ExtractFlowData ( data ) ;
76+ const flowdata = ExtractFlowData ( data ) ;
7777
7878const Points = getPoints ( data ) ;
7979const Voltages = Points . map ( d => d . value ) ;
@@ -182,7 +182,7 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
182182
183183 const [ netfiltervalue , setNetFilterValue ] = useState ( [ 0 , 800 ] ) ;
184184
185- const [ flowfiltervalue , setFlowFilterValue ] = useState ( [ 0 , 800 ] ) ;
185+ const [ flowfiltervalue , setFlowFilterValue ] = useState ( [ 0 , 120 ] ) ;
186186
187187 const [ loadfiltervalue , setLoadFilterValue ] = useState ( [ 0 , countyloaddata . maxPd ] ) ;
188188
@@ -213,26 +213,32 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
213213 lat : feature . geometry . coordinates [ 1 ]
214214 } )
215215 } else if ( feature . geometry . type === "LineString" && lineNameSelectItems . includes ( feature . properties . NAME ) ) {
216+ var RATE_A ;
217+ if ( feature . properties . RATE_A == 0 ) {
218+ RATE_A = 10000 ;
219+ } else {
220+ RATE_A = feature . properties . RATE_A ;
221+ }
222+ var loading = Math . abs ( feature . properties . PF / RATE_A ) * 100 ;
216223 if ( feature . properties . PF > 0 ) {
217224 const [ origin , dest ] = feature . properties . NAME . split ( ' -- ' )
218225 flows . push ( {
219226 origin : origin ,
220227 dest : dest ,
221- count : Math . abs ( feature . properties . PF )
228+ count : feature . properties . KV ,
229+ loading : loading
222230 } )
223231 } else {
224232 const [ dest , origin ] = feature . properties . NAME . split ( ' -- ' )
225233 flows . push ( {
226234 origin : origin ,
227235 dest : dest ,
228- count : Math . abs ( feature . properties . PF )
236+ count : feature . properties . KV ,
237+ loading : loading
229238 } )
230239 }
231-
232240 }
233-
234241 } )
235-
236242 } else if ( busNameSelectItems . length > 0 ) {
237243
238244 data . features . forEach ( feature => {
@@ -244,63 +250,80 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
244250 lat : feature . geometry . coordinates [ 1 ]
245251 } )
246252 } else if ( feature . geometry . type === "LineString" && feature . properties . NAME . split ( ' -- ' ) . some ( r => busNameSelectItems . includes ( r ) ) ) {
253+ var RATE_A ;
254+ if ( feature . properties . RATE_A == 0 ) {
255+ RATE_A = 10000 ;
256+ } else {
257+ RATE_A = feature . properties . RATE_A ;
258+ }
259+
260+ var loading = Math . abs ( feature . properties . PF / RATE_A ) * 100 ;
247261 if ( feature . properties . PF > 0 ) {
248262 const [ origin , dest ] = feature . properties . NAME . split ( ' -- ' )
249263 flows . push ( {
250264 origin : origin ,
251265 dest : dest ,
252- count : Math . abs ( feature . properties . PF )
266+ count : feature . properties . KV ,
267+ loading : loading
253268 } )
254269 } else {
255270 const [ dest , origin ] = feature . properties . NAME . split ( ' -- ' )
256271 flows . push ( {
257272 origin : origin ,
258273 dest : dest ,
259- count : Math . abs ( feature . properties . PF )
274+ count : feature . properties . KV ,
275+ loading : loading
260276 } )
261277 }
262278
263279 }
264280
265281 } )
266282 }
267- else {
283+ else {
268284 data . features . forEach ( feature => {
269285 if ( feature . geometry . type === "Point" && netfiltervalue [ 0 ] <= feature . properties . KVlevels [ 0 ] &&
270- feature . properties . KVlevels [ 0 ] <= netfiltervalue [ 1 ] &&
271- flowfiltervalue [ 0 ] <= feature . properties . KVlevels [ 0 ] &&
272- feature . properties . KVlevels [ 0 ] <= flowfiltervalue [ 1 ] ) {
286+ feature . properties . KVlevels [ 0 ] <= netfiltervalue [ 1 ] ) {
273287 locations . push ( {
274288 id : feature . properties . NAME ,
275289 name : feature . properties . NAME ,
276290 lon : feature . geometry . coordinates [ 0 ] ,
277291 lat : feature . geometry . coordinates [ 1 ]
278292 } )
279293 } else if ( feature . geometry . type === "LineString" && netfiltervalue [ 0 ] <= feature . properties . KV &&
280- feature . properties . KV <= netfiltervalue [ 1 ] &&
281- flowfiltervalue [ 0 ] <= feature . properties . KV &&
282- feature . properties . KV <= flowfiltervalue [ 1 ] ) {
283- if ( feature . properties . PF > 0 ) {
284- const [ origin , dest ] = feature . properties . NAME . split ( ' -- ' )
285- flows . push ( {
286- origin : origin ,
287- dest : dest ,
288- count : Math . abs ( feature . properties . PF )
289- } )
290- } else {
291- const [ dest , origin ] = feature . properties . NAME . split ( ' -- ' )
292- flows . push ( {
293- origin : origin ,
294- dest : dest ,
295- count : Math . abs ( feature . properties . PF )
296- } )
297- }
298-
294+ feature . properties . KV <= netfiltervalue [ 1 ] ) {
295+ var RATE_A ;
296+ if ( feature . properties . RATE_A == 0 ) {
297+ RATE_A = 10000 ;
298+ } else {
299+ RATE_A = feature . properties . RATE_A ;
300+ }
301+ var loading = Math . abs ( feature . properties . PF / RATE_A ) * 100.0 ;
302+
303+ if ( flowfiltervalue [ 0 ] <= loading && loading <= flowfiltervalue [ 1 ] ) {
304+ if ( feature . properties . PF > 0 ) {
305+ const [ origin , dest ] = feature . properties . NAME . split ( ' -- ' )
306+ flows . push ( {
307+ origin : origin ,
308+ dest : dest ,
309+ count : feature . properties . KV ,
310+ loading : loading
311+ } )
312+ } else {
313+ const [ dest , origin ] = feature . properties . NAME . split ( ' -- ' )
314+ flows . push ( {
315+ origin : origin ,
316+ dest : dest ,
317+ count : feature . properties . KV ,
318+ loading : loading
319+ } )
320+ }
321+ }
299322 }
300-
301323 } )
302- }
303- const newflowdata = { locations : locations , flows : flows }
324+ }
325+
326+ const newflowdata = { locations : locations , flows : flows , maxloading : 120 }
304327 setFlowData ( newflowdata ) ;
305328 } , [ data , netfiltervalue , flowfiltervalue , lineNameSelectItems ] ) ;
306329
@@ -554,16 +577,15 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
554577 toggleMsgLoader ( ) ; // close loading
555578 } , [ ouputMes ] ) ;
556579
557-
558-
559580 const handleNetLayerChange = ( event ) => {
560581 setNetLayerActive ( event . target . checked ) ;
561582 setNetFilterValue ( [ 0 , 800 ] ) ;
562583 } ;
563584
564585
565586 const handleFlowLayerChange = ( event ) => {
566- setFlowLayerActive ( event . target . checked ) ;
587+ setFlowLayerActive ( event . target . checked ) ;
588+ setFlowFilterValue ( [ 0 , 120 ] ) ;
567589 } ;
568590
569591 const handleLoadLayerChange = ( event ) => {
@@ -640,16 +662,29 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
640662 if ( netfiltervalue [ 0 ] <= KV && KV <= netfiltervalue [ 1 ] ) return KV ;
641663 }
642664 } else {
643- /* Line layer */
644- return data . properties . KV ;
665+ if ( data . geometry . type == 'LineString' ) { /* Line layer */
666+ /* Uncomment to activate flow-based filtering
667+ var RATE_A;
668+ if(data.properties.RATE_A == 0) {
669+ RATE_A = 10000;
670+ } else {
671+ RATE_A = data.properties.RATE_A;
672+ }
673+ var loading = Math.abs(data.properties.PF / RATE_A)*100;
674+ if(flowfiltervalue[0] <= loading && loading <= flowfiltervalue[1]) {
675+ return data.properties.KV;
676+ }
677+ */
678+ return data . properties . KV ;
679+ }
645680 }
646681 }
647682
648683 return - 1 ; // This is beyond the range so filter will filter out this data point.
649684 }
650685
651686 function getFlowFilterValue ( data ) {
652- console . log ( data )
687+
653688 }
654689
655690 function getGenFilterValue ( data ) {
@@ -777,7 +812,7 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
777812
778813 extensions : [ new DataFilterExtension ( { filtersize : 1 } ) ] ,
779814 updateTriggers : {
780- getFilterValue : [ netfiltervalue , lineNameSelectItems , busNameSelectItems ]
815+ getFilterValue : [ netfiltervalue , lineNameSelectItems , busNameSelectItems , flowfiltervalue ]
781816 }
782817 } ) ,
783818
@@ -1293,9 +1328,9 @@ export default function App({ refdata = data, refflowdata = flowdata, ggdata = g
12931328 valueLabelDisplay = "auto"
12941329 onChange = { handleFlowRangeFilterChange }
12951330 getAriaValueText = { valuetext }
1296- step = { 100 }
1331+ step = { 10 }
12971332 min = { 0 }
1298- max = { 800 }
1333+ max = { 120 }
12991334 >
13001335 </ Slider > </ div > )
13011336 }
0 commit comments