All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.maplibre.geojson.utils.GeoJsonUtils Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
package org.maplibre.geojson.utils;

/**
 * GeoJson utils class contains method that can be used throughout geojson package.
 *
 * @since 4.3.0
 */
public class GeoJsonUtils {

  private static double ROUND_PRECISION = 10000000.0;
  private static long MAX_DOUBLE_TO_ROUND = (long) (Long.MAX_VALUE / ROUND_PRECISION);

  /**
   * Trims a double value to have only 7 digits after period.
   *
   * @param value to be trimed
   * @return trimmed value
   */
  public static double trim(double value) {
    if (value > MAX_DOUBLE_TO_ROUND || value < -MAX_DOUBLE_TO_ROUND) {
      return value;
    }
    return Math.round(value * ROUND_PRECISION) / ROUND_PRECISION;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy