React Three Map - v1.0.9
    Preparing search index...
    • Converts a BufferGeometry to PostGIS POLYHEDRALSURFACE Z WKT format.

      This function extracts all triangular faces from the geometry and converts them to geographic coordinates suitable for storage in PostGIS with geometry(POLYHEDRALSURFACEZ, 4326) column type.

      Parameters

      • geometry: BufferGeometry

        The Three.js BufferGeometry to convert

      • options: BufferGeometryToWKTOptions

        Conversion options including the geographic origin

      Returns string

      WKT string in POLYHEDRALSURFACE Z format

      The output format is:

      POLYHEDRALSURFACE Z (
      ((lng1 lat1 alt1, lng2 lat2 alt2, lng3 lat3 alt3, lng1 lat1 alt1)),
      ...
      )

      Note: PostGIS uses (longitude, latitude, altitude) order (X, Y, Z).

      Error if BufferGeometry has no position attribute

      Error if BufferGeometry has no triangular faces

      import { bufferGeometryToWKT } from '@wendylabsinc/react-three-map/maplibre';
      import { BoxGeometry } from 'three';

      const geometry = new BoxGeometry(100, 100, 100);
      const origin = { latitude: 51.5074, longitude: -0.1278, altitude: 0 };

      const wkt = bufferGeometryToWKT(geometry, { origin });
      // Store in PostGIS: INSERT INTO geofences (geom) VALUES (ST_GeomFromText(wkt, 4326))

      wktToBufferGeometry for the inverse operation