55} from 'mobx' ;
66import { IColumnFilter } from './ColumnFilterCheckBoxList' ;
77import { ColumnFilterArray } from './ColumnFilterArray' ;
8- import { ColumnFilterCombo , initStartYear , initEndYear , initCityPopSize } from './columnFilterCombo' ;
8+ import { ColumnFilterCombo , initStartYear , initEndYear , initCityPopSize , initPoilceStations } from './columnFilterCombo' ;
99import * as FC from './ColumnFilterCheckBoxList' ;
1010import { IFilterChecker } from './FilterChecker' ;
1111import GroupBy , { initGroupMap } from './GroupBy' ;
@@ -68,9 +68,9 @@ class FilterStore implements IFilterStore {
6868 this . roads = new ColumnFilterArray ( 'Road' , 'rd' , false ) ;
6969 this . roadSegment = new ColumnFilterArray ( 'RoadSegment' , 'rds' , false ) ;
7070 this . cities = new ColumnFilterArray ( 'City' , 'city' , false ) ;
71- this . zonesNames = new ColumnFilterArray ( 'PoliceStation' , 'pStatios' , true ) ;
7271 this . streets = new ColumnFilterArray ( 'Street' , 'st' , false ) ;
7372 this . cityPopSizeRange = initCityPopSize ( ) ;
73+ this . zoneName = initPoilceStations ( ) ;
7474 // who
7575 this . genderTypes = FC . initGenderTypes ( ) ;
7676 this . ageTypes = FC . initAgeTypes ( ) ;
@@ -205,10 +205,12 @@ class FilterStore implements IFilterStore {
205205 }
206206
207207 @observable
208- zonesNames : ColumnFilterArray ;
209- setZonesNames = ( values : string [ ] ) => {
210- this . zonesNames . setFilter ( values ) ;
208+ zoneName : ColumnFilterCombo ;
209+ setZonesName = async ( value : string ) => {
210+ this . zoneName . setFilter ( value ) ;
211+ this . geoFilter = await this . getGeoFilter ( ) ;
211212 }
213+
212214
213215 @action
214216 updateModerateDisabledState = ( ) => {
@@ -601,7 +603,7 @@ class FilterStore implements IFilterStore {
601603 submitGroupByYears = ( ) => {
602604 const filtermatch = this . getfilterBySeverityAndCity ( ) ;
603605 const filter = createFilterQureyByGroup ( filtermatch , 'year' ) ;
604- AccidentService . fetchGetGroupBy ( filter )
606+ AccidentService . fetchGroupBy ( filter , this . geoFilter )
605607 . then ( ( data : ItemCount [ ] | undefined ) => {
606608 if ( data !== undefined ) {
607609 const dataPadded = padDataYearsWith0 ( data , this . startYear . queryValue , this . endYear . queryValue ) ;
@@ -623,7 +625,7 @@ class FilterStore implements IFilterStore {
623625 const range = JSON . parse ( this . cityPopSizeRange . queryValue . toString ( ) ) ;
624626 const filtermatch = this . getFilterQueryString ( null ) ;
625627 const filter = createFilterQureyByGroup ( filtermatch , 'year' , range . min , range . max ) ;
626- AccidentService . fetchGetGroupBy ( filter )
628+ AccidentService . fetchGroupBy ( filter , this . geoFilter )
627629 . then ( ( data : ItemCount2 [ ] | undefined ) => {
628630 if ( data !== undefined ) {
629631 const dataPadded = padDataYearsWith0 ( data , this . startYear . queryValue , this . endYear . queryValue ) ;
@@ -643,7 +645,7 @@ class FilterStore implements IFilterStore {
643645 const filtermatch = this . getFilterQueryString ( null ) ;
644646 const filter = createFilterQureyByGroup ( filtermatch , aGroupBy . value , range . min , range . max , '' , limit , this . GroupBySort ) ;
645647 // logger.log(filter);
646- AccidentService . fetchGetGroupBy ( filter )
648+ AccidentService . fetchGroupBy ( filter , this . geoFilter )
647649 . then ( ( data : any | undefined ) => {
648650 if ( aGroupBy . transformFetchResult ) {
649651 data = aGroupBy . transformFetchResult ( data ) ;
@@ -668,7 +670,7 @@ class FilterStore implements IFilterStore {
668670 const filtermatch = this . getFilterQueryString ( null ) ;
669671 const filter = createFilterQureyByGroup ( filtermatch , aGroupBy . value , range . min , range . max , groupName2 , aGroupBy . limit ) ;
670672 // logger.log(filter)
671- AccidentService . fetchGetGroupBy ( filter )
673+ AccidentService . fetchGroupBy ( filter , this . geoFilter )
672674 . then ( ( data : ItemCount2 [ ] | undefined ) => {
673675 if ( data !== undefined && data . length > 0 ) {
674676 try {
@@ -759,7 +761,7 @@ class FilterStore implements IFilterStore {
759761 this . setBrowserQueryString ( ) ;
760762 // logger.log(filter);
761763 this . rootStore . mapStore . updateIsSetBounds ( this . cities . arrValues , this . roadSegment . arrValues ) ;
762- AccidentService . fetchInvolvedList ( filter )
764+ AccidentService . fetchInvolvedList ( filter , null )
763765 . then ( ( res : any | undefined ) => {
764766 if ( res && res . data !== null && res . data !== undefined ) {
765767 // this.updateAllInjuries(res.data);
@@ -831,9 +833,16 @@ class FilterStore implements IFilterStore {
831833 query += createFilterQureyByCityPop ( range . min , range . max )
832834 return query ;
833835 }
836+
837+ @observable
838+ geoFilter : GeoFilter | null = null ;
834839
835840 getGeoFilter = async ( ) => {
836- let geoPolygon = await loadAreaPolygon ( "תחנת תל אביב צפון" ) ;
841+ const policeStationName = this . zoneName . queryValue as string ;
842+ if ( ! policeStationName || policeStationName . trim ( ) === '' ) {
843+ return null ;
844+ }
845+ let geoPolygon = await loadAreaPolygon ( policeStationName ) ;
837846 let geoFilter : GeoFilter = { geo : geoPolygon } ;
838847 return geoFilter ;
839848 }
0 commit comments