<commit_before>import L from 'leaflet';
import { isFunction } from 'lodash';
import PropTypes from 'prop-types';
import 'proj4leaflet';

import { connect } from "react-redux";
import { bindActionCreators } from 'redux';
import { actions as mappingActions } from '../redux/modules/mapping';

import { Path } from 'react-leaflet';

require('react-leaflet-markercluster/dist/styles.min.css');

function mapStateToProps(state) {
  return {
    mapping: state.mapping,

  };
}

function mapDispatchToProps(dispatch) {
  return {
    mappingActions: bindActionCreators(mappingActions, dispatch),
  };
}


export class ProjGeoJson_ extends Path {
  componentWillMount() {
    super.componentWillMount();
    const { mappingProps, ...props } = this.props;

    props.onEachFeature=function (feature, layer) {
        //This could be the problem in /stadtplan 
        //----wait for regressions -.-
        //layer._leaflet_id = feature.id;
        //----

        //TODO set a offset so that the Tooltip is shown in the current map
        layer.feature=feature
        layer.on('click',props.featureClickHandler);
        let zoffset=new L.point(0,0);
        if (feature.selected) {
          //ugly winning: a direct call of bringToFront has no effect -.-
          setTimeout(function () {
            try {
              layer.bringToFront();
            }
            catch (err) {
              //ugly winning
            }
            if (props.labeler) {
              layer.bindTooltip(props.labeler(feature), {className: 'customGeoJSONFeatureTooltipClass', permanent:true, direction:'center', offset: zoffset, opacity: '0.9'});
            }
          }, 10);
        }
        else {
            if (props.labeler) {
              layer.bindTooltip(props.labeler(feature), {className: 'customGeoJSONFeatureTooltipClass', permanent:true, direction:'center', offset: zoffset, opacity: '0.9'});
            }
        }
        if (props.hoverer) {
          let theStyle=props.style(feature);

          layer.bindTooltip(""+props.hoverer(feature), {offset: L.point(theStyle.radius, 0), direction:'right'});
          layer.on('mouseover', function() { layer.openPopup(); });
          layer.on('mouseout', function() { layer.closePopup(); });
        }
      };

    props.pointToLayer = (feature, latlng) => {
        if (props.style) {
            let theStyle = props.style(feature);
            let marker = null;
            if (theStyle.svg) {
                var divIcon = L.divIcon({
                    className: "leaflet-data-marker",
                    html: theStyle.svg,
                    iconAnchor: [
                        theStyle.svgSize / 2,
                        theStyle.svgSize / 2
                    ],
                    iconSize: [theStyle.svgSize, theStyle.svgSize]
                });
                marker = L.marker(latlng, {icon: divIcon});
            } 
            else {
                marker = L.circleMarker(latlng);
            }
            return marker;
        }
    }


    
    var geojson=L.Proj.geoJson(mappingProps.featureCollection, props);

    if (this.props.clusteredMarkers) {
        this.leafletElement = this.props.clusteredMarkers.clearLayers();
        this.leafletElement = this.props.clusteredMarkers.addLayer(geojson);
        //var visibleOne = this.clusteredMarkers.getVisibleParent(this.props.mapping.);
        let markers = this.props.clusteredMarkers.getLayers();
        for (let marker of markers) {
            if (marker.feature.selected === true) {
                let parent = this.props.clusteredMarkers.getVisibleParent(marker);
                if (parent.spiderfy) {
                    //   console.log("will spiderfy cluster of feature "+marker.feature.id )
                    if (this.props.mapRef.leafletElement.getZoom()>=(this.props.selectionSpiderfyMinZoom||12)) {
                        setTimeout(function () {
                            try {
                                parent.spiderfy();
                            } catch (err) {
                                //ugly winning
                            }
                        }, 1);
                    }
                    //   console.log("have spiderfied cluster of feature "+marker.feature.id )
                }
            }
        }
    } else {
        this.leafletElement = geojson;
    }
  }

  createLeafletElement () {
  }

  componentDidUpdate(prevProps) {
    if (isFunction(this.props.style)) {
      this.setStyle(this.props.style);
    } else {
      this.setStyleIfChanged(prevProps, this.props);<commit_msg>:bug: working on #18: working on a problem that occurs when using the point gazetteer<commit_after>import L from 'leaflet';
import { isFunction } from 'lodash';
import PropTypes from 'prop-types';
import 'proj4leaflet';

import { connect } from "react-redux";
import { bindActionCreators } from 'redux';
import { actions as mappingActions } from '../redux/modules/mapping';

import { Path } from 'react-leaflet';

require('react-leaflet-markercluster/dist/styles.min.css');

function mapStateToProps(state) {
  return {
    mapping: state.mapping,

  };
}

function mapDispatchToProps(dispatch) {
  return {
    mappingActions: bindActionCreators(mappingActions, dispatch),
  };
}


export class ProjGeoJson_ extends Path {
  componentWillMount() {
    super.componentWillMount();
    const { mappingProps, ...props } = this.props;

    props.onEachFeature=function (feature, layer) {
        //This could be the problem in /stadtplan 
        //----wait for regressions -.-
        //layer._leaflet_id = feature.id;
        //----

        //TODO set a offset so that the Tooltip is shown in the current map
        layer.feature=feature
        layer.on('click',props.featureClickHandler);
        let zoffset=new L.point(0,0);
        if (feature.selected) {
          //ugly winning: a direct call of bringToFront has no effect -.-
          setTimeout(function () {
            try {
              layer.bringToFront();
            }
            catch (err) {
              //ugly winning
            }
            if (props.labeler) {
              layer.bindTooltip(props.labeler(feature), {className: 'customGeoJSONFeatureTooltipClass', permanent:true, direction:'center', offset: zoffset, opacity: '0.9'});
            }
          }, 10);
        }
        else {
            if (props.labeler) {
              layer.bindTooltip(props.labeler(feature), {className: 'customGeoJSONFeatureTooltipClass', permanent:true, direction:'center', offset: zoffset, opacity: '0.9'});
            }
        }
        if (props.hoverer) {
          let theStyle=props.style(feature);

          layer.bindTooltip(""+props.hoverer(feature), {offset: L.point(theStyle.radius, 0), direction:'right'});
          layer.on('mouseover', function() { layer.openPopup(); });
          layer.on('mouseout', function() { layer.closePopup(); });
        }
      };

    props.pointToLayer = (feature, latlng) => {
        if (props.style) {
            let theStyle = props.style(feature);
            let marker = null;
            if (theStyle.svg) {
                var divIcon = L.divIcon({
                    className: "leaflet-data-marker",
                    html: theStyle.svg,
                    iconAnchor: [
                        theStyle.svgSize / 2,
                        theStyle.svgSize / 2
                    ],
                    iconSize: [theStyle.svgSize, theStyle.svgSize]
                });
                marker = L.marker(latlng, {icon: divIcon});
            } 
            else {
                marker = L.circleMarker(latlng);
            }
            return marker;
        }
    }


    
    var geojson=L.Proj.geoJson(mappingProps.featureCollection, props);

    if (this.props.clusteredMarkers) {
        this.leafletElement = this.props.clusteredMarkers.clearLayers();
        this.leafletElement = this.props.clusteredMarkers.addLayer(geojson);
        //var visibleOne = this.clusteredMarkers.getVisibleParent(this.props.mapping.);
        let markers = this.props.clusteredMarkers.getLayers();
        for (let marker of markers) {
            if (marker.feature.selected === true) {
                let parent = this.props.clusteredMarkers.getVisibleParent(marker);
                if (parent && parent.spiderfy) {
                    //   console.log("will spiderfy cluster of feature "+marker.feature.id )
                    if (this.props.mapRef.leafletElement.getZoom()>=(this.props.selectionSpiderfyMinZoom||12)) {
                        setTimeout(function () {
                            try {
                                parent.spiderfy();
                            } catch (err) {
                                //ugly winning
                            }
                        }, 1);
                    }
                    //   console.log("have spiderfied cluster of feature "+marker.feature.id )
                }
            }
        }
    } else {
        this.leafletElement = geojson;
    }
  }

  createLeafletElement () {
  }

  componentDidUpdate(prevProps) {
    if (isFunction(this.props.style)) {
      this.setStyle(this.props.style);
    } else {
      this.setStyleIfChanged(prevProps, this.props);
{'fraction_non_alphanumeric': 0.11763436218432981, 'fraction_numerical': 0.003453485862292251, 'mean_word_length': 1.7670946551209317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5423849', 'n_tokens_mistral': 2599, 'n_tokens_neox': 2511, 'n_words': 504}