<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import Cismap from '../containers/Cismap';

import { connect } from "react-redux";
import { Tooltip } from 'react-bootstrap';

import { actions as mappingActions } from '../redux/modules/mapping';
import { actions as uiStateActions } from '../redux/modules/uiState';
import { actions as stadtplanActions } from '../redux/modules/stadtplan';
import {routerActions} from 'react-router-redux'

import { bindActionCreators } from 'redux';

import { getFeatureStyler, featureHoverer, getPoiClusterIconCreatorFunction } from '../utils/stadtplanHelper';

import Loadable from 'react-loading-overlay';
import queryString from 'query-string';

import StadtplanInfo from '../components/StadtplanInfo';
import StadtplanModalApplicationMenu from '../components/StadtplanModalApplicationMenu';
import PhotoLightbox from './PhotoLightbox';

import 'react-image-lightbox/style.css';

function mapStateToProps(state) {
  return {
    uiState: state.uiState,
    mapping: state.mapping,
    routing: state.routing,
    stadtplan: state.stadtplan,
  };
}

function mapDispatchToProps(dispatch) {
  return {
    mappingActions: bindActionCreators(mappingActions, dispatch),
    uiStateActions: bindActionCreators(uiStateActions, dispatch),
    stadtplanActions: bindActionCreators(stadtplanActions, dispatch),
    routingActions: bindActionCreators(routerActions, dispatch),
  };
}

export class Stadtplan_ extends React.Component {
    constructor(props, context) {
      super(props, context);
      this.gazeteerhHit=this.gazeteerhHit.bind(this);
      this.searchButtonHit=this.searchButtonHit.bind(this);
      this.featureClick=this.featureClick.bind(this);
      this.gotoHome=this.gotoHome.bind(this);
      this.doubleMapClick=this.doubleMapClick.bind(this);
      this.searchTooltip=this.searchTooltip.bind(this);
      this.selectNextIndex=this.selectNextIndex.bind(this);
      this.selectPreviousIndex=this.selectPreviousIndex.bind(this);
      this.createfeatureCollectionByBoundingBox=this.createfeatureCollectionByBoundingBox.bind(this);
      this.filterChanged=this.filterChanged.bind(this);
      this.resetFilter=this.resetFilter.bind(this);
      this.centerOnPoint=this.centerOnPoint.bind(this);
      this.props.mappingActions.setBoundingBoxChangedTrigger(this.createfeatureCollectionByBoundingBox);
    }
    componentWillUnmount() {
        // console.log("Ehrenamt unmount")
    }

    componentWillMount() {
        // console.log("Ehrenamt mount")
        this.dataLoaded=false;
        this.loadThePOIs().then((data) => {
            this.dataLoaded=true;
        });
        //this.props.uiStateActions.setApplicationMenuActiveKey("filtertab");
      }
    componentWillUpdate() {
      
        if (this.props.stadtplan.pois.length===0){
            return;
        }
        // let urlCart=queryString.parse(this.props.routing.location.search).cart;
        // let urlCartIds=new Set();
        // if (urlCart){
        //     urlCartIds=new Set(urlCart.split(",").sort((a,b)=>parseInt(a,10)-parseInt(b,10)));
        // }
        // let cartIds=new Set(this.props.ehrenamt.cart.map(x=>x.id).sort((a,b)=>parseInt(a,10)-parseInt(b,10)));

        // let missingIdsInCart=new Set([...urlCartIds].filter(x => !cartIds.has(x)));

        // if (missingIdsInCart.size>0) {
        //     this.props.ehrenamtActions.addToCartByIds(Array.from(missingIdsInCart));
        // }        
        
        // let newUrlCartArr=Array.from(cartIds).sort((a,b)=>parseInt(a,10)-parseInt(b,10));
    
        // let newUrlCart=newUrlCartArr.join();

        // if (urlCart!==newUrlCart && newUrlCart.length>0){
            
        //     let pn=this.props.routing.location.pathname;
        //     if (pn.indexOf("stadtplan")===-1){ 
        //         pn="/stadtplan"; //in certain conditions the pathname does not contain ehrenamt. fix that. 
        //     }
        //     let newRoute= pn + modifyQueryPart(this.props.routing.location.search, {
        //         cart: newUrlCart
        //     });
        //     console.log("push new route:"+newRoute);
        //     this.props.routingActions.push(newRoute);
        // }
    }
     





    loadThePOIs() {
        var promise = new Promise((resolve, reject) => {
            setTimeout(() => {
                this.props.stadtplanActions.loadPOIs();
                resolve('ok');
            }, 100);
        });
        return promise;
    }
    createfeatureCollectionByBoundingBox(bbox) {
       this.props.stadtplanActions.createFeatureCollectionFromPOIs(bbox)
    }

    gazeteerhHit(selectedObject) {
        if (selectedObject && selectedObject[0] && selectedObject[0].more && selectedObject[0].more.pid) {
            //this.props.stadtplanActions.setPoiGazHit(selectedObject[0].more.pid);
            this.props.stadtplanActions.setSelectedPOI(selectedObject[0].more.pid);
        }
    }

    searchButtonHit(event) {

    }

    featureClick(event){
      if (event.target.feature) {
        this.props.mappingActions.setSelectedFeatureIndex(event.target.feature.index);
      }
    }

    doubleMapClick(event) {

    }

    gotoHome() {
      //x1=361332.75015625&y1=5669333.966678483&x2=382500.79703125&y2=5687261.576954328
      this.cismapRef.wrappedInstance.gotoHomeBB()
    }<commit_msg>:bug: working on #31: fixed a problem with the selection from the gaz box<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import Cismap from '../containers/Cismap';

import { connect } from "react-redux";
import { Tooltip } from 'react-bootstrap';

import { actions as mappingActions } from '../redux/modules/mapping';
import { actions as uiStateActions } from '../redux/modules/uiState';
import { actions as stadtplanActions } from '../redux/modules/stadtplan';
import {routerActions} from 'react-router-redux'

import { bindActionCreators } from 'redux';

import { getFeatureStyler, featureHoverer, getPoiClusterIconCreatorFunction } from '../utils/stadtplanHelper';

import Loadable from 'react-loading-overlay';
import queryString from 'query-string';

import StadtplanInfo from '../components/StadtplanInfo';
import StadtplanModalApplicationMenu from '../components/StadtplanModalApplicationMenu';
import PhotoLightbox from './PhotoLightbox';

import 'react-image-lightbox/style.css';

function mapStateToProps(state) {
  return {
    uiState: state.uiState,
    mapping: state.mapping,
    routing: state.routing,
    stadtplan: state.stadtplan,
  };
}

function mapDispatchToProps(dispatch) {
  return {
    mappingActions: bindActionCreators(mappingActions, dispatch),
    uiStateActions: bindActionCreators(uiStateActions, dispatch),
    stadtplanActions: bindActionCreators(stadtplanActions, dispatch),
    routingActions: bindActionCreators(routerActions, dispatch),
  };
}

export class Stadtplan_ extends React.Component {
    constructor(props, context) {
      super(props, context);
      this.gazeteerhHit=this.gazeteerhHit.bind(this);
      this.searchButtonHit=this.searchButtonHit.bind(this);
      this.featureClick=this.featureClick.bind(this);
      this.gotoHome=this.gotoHome.bind(this);
      this.doubleMapClick=this.doubleMapClick.bind(this);
      this.searchTooltip=this.searchTooltip.bind(this);
      this.selectNextIndex=this.selectNextIndex.bind(this);
      this.selectPreviousIndex=this.selectPreviousIndex.bind(this);
      this.createfeatureCollectionByBoundingBox=this.createfeatureCollectionByBoundingBox.bind(this);
      this.filterChanged=this.filterChanged.bind(this);
      this.resetFilter=this.resetFilter.bind(this);
      this.centerOnPoint=this.centerOnPoint.bind(this);
      this.props.mappingActions.setBoundingBoxChangedTrigger(this.createfeatureCollectionByBoundingBox);
    }
    componentWillUnmount() {
        // console.log("Ehrenamt unmount")
    }

    componentWillMount() {
        // console.log("Ehrenamt mount")
        this.dataLoaded=false;
        this.loadThePOIs().then((data) => {
            this.dataLoaded=true;
        });
        //this.props.uiStateActions.setApplicationMenuActiveKey("filtertab");
      }
    componentWillUpdate() {
      
        if (this.props.stadtplan.pois.length===0){
            return;
        }
        // let urlCart=queryString.parse(this.props.routing.location.search).cart;
        // let urlCartIds=new Set();
        // if (urlCart){
        //     urlCartIds=new Set(urlCart.split(",").sort((a,b)=>parseInt(a,10)-parseInt(b,10)));
        // }
        // let cartIds=new Set(this.props.ehrenamt.cart.map(x=>x.id).sort((a,b)=>parseInt(a,10)-parseInt(b,10)));

        // let missingIdsInCart=new Set([...urlCartIds].filter(x => !cartIds.has(x)));

        // if (missingIdsInCart.size>0) {
        //     this.props.ehrenamtActions.addToCartByIds(Array.from(missingIdsInCart));
        // }        
        
        // let newUrlCartArr=Array.from(cartIds).sort((a,b)=>parseInt(a,10)-parseInt(b,10));
    
        // let newUrlCart=newUrlCartArr.join();

        // if (urlCart!==newUrlCart && newUrlCart.length>0){
            
        //     let pn=this.props.routing.location.pathname;
        //     if (pn.indexOf("stadtplan")===-1){ 
        //         pn="/stadtplan"; //in certain conditions the pathname does not contain ehrenamt. fix that. 
        //     }
        //     let newRoute= pn + modifyQueryPart(this.props.routing.location.search, {
        //         cart: newUrlCart
        //     });
        //     console.log("push new route:"+newRoute);
        //     this.props.routingActions.push(newRoute);
        // }
    }
     





    loadThePOIs() {
        var promise = new Promise((resolve, reject) => {
            setTimeout(() => {
                this.props.stadtplanActions.loadPOIs();
                resolve('ok');
            }, 100);
        });
        return promise;
    }
    createfeatureCollectionByBoundingBox(bbox) {
       this.props.stadtplanActions.createFeatureCollectionFromPOIs(bbox)
    }

    gazeteerhHit(selectedObject) {
        if (selectedObject && selectedObject[0] && selectedObject[0].more && (selectedObject[0].more.pid||selectedObject[0].more.kid)) {
            //this.props.stadtplanActions.setPoiGazHit(selectedObject[0].more.pid);
            this.props.stadtplanActions.setSelectedPOI(selectedObject[0].more.pid||selectedObject[0].more.kid);
        }
    }

    searchButtonHit(event) {

    }

    featureClick(event){
      if (event.target.feature) {
        this.props.mappingActions.setSelectedFeatureIndex(event.target.feature.index);
      }
    }

    doubleMapClick(event) {

    }

    gotoHome() {
      //x1=361332.75015625&y1=5669333.966678483&x2=382500.79703125&y2=5687261.576954328
      this.cismapRef.wrappedInstance.gotoHomeBB()
    }
{'fraction_non_alphanumeric': 0.13346908552388004, 'fraction_numerical': 0.016660496112550906, 'mean_word_length': 3.031716417910448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2105425', 'n_tokens_mistral': 3359, 'n_tokens_neox': 3284, 'n_words': 451}