1

I use a function of DBSCAN for clustering, that takes the EPS value as a parameter (radius that defines which points will be grouped together).

To set the EPS I use the following switch case:

    let eps = 0;
    switch (true) {
      case (zoom >= 19):
        eps = 0.00001;
        break;
      case (zoom > 18):
        eps = 0.00002;
        break;
      case (zoom > 16):
        eps = 0.0003;
        break;
      case (zoom > 14):
        eps = 0.0014;
        break;
      case (zoom > 12):
        eps = 0.0024;
        break;
      case (zoom > 10):
        eps = 0.0082;
        break;
      case (zoom > 8):
        eps = 0.032;
        break;
      case (zoom > 6):
        eps = 0.2;
        break;
      case (zoom > 4):
        eps = 0.45;
        break;
      default:
        eps = 3;
    }

How could I replace this switch case with fixed values ​​and conditions for some calculation?

I use this method to get current map zoom:

const handleRegionChange = ({ longitudeDelta, latitudeDelta }: Region) => {
    const zoomLevel = Math.log(360 / Math.max(longitudeDelta, latitudeDelta)) / Math.LN2;

    if (zoomLevel !== zoom) {
      setZoom(Math.ceil(zoomLevel));
    }
};

this method always returns a value from 1 to 20.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.