@watergis/maplibre-gl-terradraw
    Preparing search index...
    • Round coordinates to given coordinate precision

      If you want to add geojson with excessive coordinate precision to TerraDraw by using addFeatures, TerraDraw raise a validation error if you add GeoJSON with excessive precision.

      use this function to make sure geojson coordinates to meet terradraw setting before adding features.

      The below is a sample usage of the function

      const drawControl = new MaplibreTerraDrawControl({
      adapterOptions: {
      coordinatePrecision: 6
      }
      })
      map.addControl(drawControl)

      map.once('load', ()=>{
      const features = [] // add your geojson features here
      const draw = drawControl.getTerradrawInstance()
      draw.addFeatures(roundFeatureCoordinates(features), 6)
      })

      Parameters

      • features: GeoJSONStoreFeatures[]

        GeoJSON feature

      • decimalPlaces: number = 9

        decimal places to 9 (default of terradraw)

      Returns {
          bbox?: BBox;
          geometry: GeoJSONStoreGeometries;
          id?: string | number;
          properties: DefinedProperties;
          type: "Feature";
      }[]

      GeoJSON feature after rounding coordinates

      • Optionalbbox?: BBox

        Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5

      • geometry: GeoJSONStoreGeometries
      • Optionalid?: string | number

        A value that uniquely identifies this feature in a https://tools.ietf.org/html/rfc7946#section-3.2.

      • properties: DefinedProperties

        Properties associated with this feature.

      • type: "Feature"

        Specifies the type of GeoJSON object.