// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.30.0
// source: geometries.sql

package sqlc

import (
	"context"
	"encoding/json"

	"github.com/jackc/pgx/v5/pgtype"
)

const bulkDeleteEntityGeometriesByEntityId = `-- name: BulkDeleteEntityGeometriesByEntityId :many
DELETE FROM entity_geometries
WHERE entity_id = $1
RETURNING geometry_id
`

func (q *Queries) BulkDeleteEntityGeometriesByEntityId(ctx context.Context, entityID pgtype.UUID) ([]pgtype.UUID, error) {
	rows, err := q.db.Query(ctx, bulkDeleteEntityGeometriesByEntityId, entityID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []pgtype.UUID{}
	for rows.Next() {
		var geometry_id pgtype.UUID
		if err := rows.Scan(&geometry_id); err != nil {
			return nil, err
		}
		items = append(items, geometry_id)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const bulkDeleteEntityGeometriesByGeometryID = `-- name: BulkDeleteEntityGeometriesByGeometryID :exec
DELETE FROM entity_geometries
WHERE geometry_id = $1
`

func (q *Queries) BulkDeleteEntityGeometriesByGeometryID(ctx context.Context, geometryID pgtype.UUID) error {
	_, err := q.db.Exec(ctx, bulkDeleteEntityGeometriesByGeometryID, geometryID)
	return err
}

const createEntityGeometries = `-- name: CreateEntityGeometries :exec
INSERT INTO entity_geometries (
    entity_id, geometry_id, project_id
)
SELECT $1, unnest($3::uuid[]), $2
ON CONFLICT DO NOTHING
`

type CreateEntityGeometriesParams struct {
	EntityID    pgtype.UUID   `json:"entity_id"`
	ProjectID   pgtype.UUID   `json:"project_id"`
	GeometryIds []pgtype.UUID `json:"geometry_ids"`
}

func (q *Queries) CreateEntityGeometries(ctx context.Context, arg CreateEntityGeometriesParams) error {
	_, err := q.db.Exec(ctx, createEntityGeometries, arg.EntityID, arg.ProjectID, arg.GeometryIds)
	return err
}

const createGeometry = `-- name: CreateGeometry :one
INSERT INTO geometries (
    id, geo_type, draw_geometry, binding, time_start, time_end, bbox, project_id
) VALUES (
    COALESCE($7::uuid, uuidv7()), $1, $2, $3, $4, $5, ST_MakeEnvelope($8::float8, $9::float8, $10::float8, $11::float8, 4326), $6
)
RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
    ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
    is_deleted, created_at, updated_at
`

type CreateGeometryParams struct {
	GeoType      int16           `json:"geo_type"`
	DrawGeometry json.RawMessage `json:"draw_geometry"`
	Binding      []byte          `json:"binding"`
	TimeStart    pgtype.Int4     `json:"time_start"`
	TimeEnd      pgtype.Int4     `json:"time_end"`
	ProjectID    pgtype.UUID     `json:"project_id"`
	ID           pgtype.UUID     `json:"id"`
	MinLng       float64         `json:"min_lng"`
	MinLat       float64         `json:"min_lat"`
	MaxLng       float64         `json:"max_lng"`
	MaxLat       float64         `json:"max_lat"`
}

type CreateGeometryRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) CreateGeometry(ctx context.Context, arg CreateGeometryParams) (CreateGeometryRow, error) {
	row := q.db.QueryRow(ctx, createGeometry,
		arg.GeoType,
		arg.DrawGeometry,
		arg.Binding,
		arg.TimeStart,
		arg.TimeEnd,
		arg.ProjectID,
		arg.ID,
		arg.MinLng,
		arg.MinLat,
		arg.MaxLng,
		arg.MaxLat,
	)
	var i CreateGeometryRow
	err := row.Scan(
		&i.ID,
		&i.GeoType,
		&i.DrawGeometry,
		&i.Binding,
		&i.TimeStart,
		&i.TimeEnd,
		&i.ProjectID,
		&i.MinLng,
		&i.MinLat,
		&i.MaxLng,
		&i.MaxLat,
		&i.IsDeleted,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const deleteEntityGeometriesByProjectID = `-- name: DeleteEntityGeometriesByProjectID :exec
DELETE FROM entity_geometries
WHERE project_id = $1
`

func (q *Queries) DeleteEntityGeometriesByProjectID(ctx context.Context, projectID pgtype.UUID) error {
	_, err := q.db.Exec(ctx, deleteEntityGeometriesByProjectID, projectID)
	return err
}

const deleteEntityGeometry = `-- name: DeleteEntityGeometry :exec
DELETE FROM entity_geometries
WHERE entity_id = $1 AND geometry_id = $2
`

type DeleteEntityGeometryParams struct {
	EntityID   pgtype.UUID `json:"entity_id"`
	GeometryID pgtype.UUID `json:"geometry_id"`
}

func (q *Queries) DeleteEntityGeometry(ctx context.Context, arg DeleteEntityGeometryParams) error {
	_, err := q.db.Exec(ctx, deleteEntityGeometry, arg.EntityID, arg.GeometryID)
	return err
}

const deleteGeometriesByIDs = `-- name: DeleteGeometriesByIDs :exec
UPDATE geometries
SET is_deleted = true
WHERE id = ANY($1::uuid[])
`

func (q *Queries) DeleteGeometriesByIDs(ctx context.Context, dollar_1 []pgtype.UUID) error {
	_, err := q.db.Exec(ctx, deleteGeometriesByIDs, dollar_1)
	return err
}

const deleteGeometry = `-- name: DeleteGeometry :exec
UPDATE geometries
SET 
    is_deleted = true
WHERE id = $1
`

func (q *Queries) DeleteGeometry(ctx context.Context, id pgtype.UUID) error {
	_, err := q.db.Exec(ctx, deleteGeometry, id)
	return err
}

const getEntityGeometriesByPairs = `-- name: GetEntityGeometriesByPairs :many
SELECT
    e.id AS entity_id,
    e.name AS entity_name,
    e.description AS entity_description,
    g.id AS geometry_id,
    g.geo_type,
    g.draw_geometry,
    g.binding,
    g.time_start,
    g.time_end
FROM (
    SELECT unnest($1::uuid[]) as eid, unnest($2::uuid[]) as gid
) as pairs
JOIN entities e ON e.id = pairs.eid
JOIN entity_geometries eg ON eg.entity_id = e.id AND eg.geometry_id = pairs.gid
JOIN geometries g ON g.id = pairs.gid
WHERE e.is_deleted = false
AND g.is_deleted = false
`

type GetEntityGeometriesByPairsParams struct {
	EntityIds   []pgtype.UUID `json:"entity_ids"`
	GeometryIds []pgtype.UUID `json:"geometry_ids"`
}

type GetEntityGeometriesByPairsRow struct {
	EntityID          pgtype.UUID     `json:"entity_id"`
	EntityName        string          `json:"entity_name"`
	EntityDescription pgtype.Text     `json:"entity_description"`
	GeometryID        pgtype.UUID     `json:"geometry_id"`
	GeoType           int16           `json:"geo_type"`
	DrawGeometry      json.RawMessage `json:"draw_geometry"`
	Binding           []byte          `json:"binding"`
	TimeStart         pgtype.Int4     `json:"time_start"`
	TimeEnd           pgtype.Int4     `json:"time_end"`
}

func (q *Queries) GetEntityGeometriesByPairs(ctx context.Context, arg GetEntityGeometriesByPairsParams) ([]GetEntityGeometriesByPairsRow, error) {
	rows, err := q.db.Query(ctx, getEntityGeometriesByPairs, arg.EntityIds, arg.GeometryIds)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetEntityGeometriesByPairsRow{}
	for rows.Next() {
		var i GetEntityGeometriesByPairsRow
		if err := rows.Scan(
			&i.EntityID,
			&i.EntityName,
			&i.EntityDescription,
			&i.GeometryID,
			&i.GeoType,
			&i.DrawGeometry,
			&i.Binding,
			&i.TimeStart,
			&i.TimeEnd,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getGeometriesByIDs = `-- name: GetGeometriesByIDs :many
SELECT 
    id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
    ST_XMin(bbox)::float8 as min_lng, 
    ST_YMin(bbox)::float8 as min_lat, 
    ST_XMax(bbox)::float8 as max_lng, 
    ST_YMax(bbox)::float8 as max_lat,
    is_deleted, created_at, updated_at
FROM geometries 
WHERE id = ANY($1::uuid[]) AND is_deleted = false
`

type GetGeometriesByIDsRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) GetGeometriesByIDs(ctx context.Context, dollar_1 []pgtype.UUID) ([]GetGeometriesByIDsRow, error) {
	rows, err := q.db.Query(ctx, getGeometriesByIDs, dollar_1)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetGeometriesByIDsRow{}
	for rows.Next() {
		var i GetGeometriesByIDsRow
		if err := rows.Scan(
			&i.ID,
			&i.GeoType,
			&i.DrawGeometry,
			&i.Binding,
			&i.TimeStart,
			&i.TimeEnd,
			&i.ProjectID,
			&i.MinLng,
			&i.MinLat,
			&i.MaxLng,
			&i.MaxLat,
			&i.IsDeleted,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getGeometriesByProjectId = `-- name: GetGeometriesByProjectId :many
SELECT 
    id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
    ST_XMin(bbox)::float8 as min_lng, 
    ST_YMin(bbox)::float8 as min_lat, 
    ST_XMax(bbox)::float8 as max_lng, 
    ST_YMax(bbox)::float8 as max_lat,
    is_deleted, created_at, updated_at
FROM geometries
WHERE project_id = $1 AND is_deleted = false
`

type GetGeometriesByProjectIdRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) GetGeometriesByProjectId(ctx context.Context, projectID pgtype.UUID) ([]GetGeometriesByProjectIdRow, error) {
	rows, err := q.db.Query(ctx, getGeometriesByProjectId, projectID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetGeometriesByProjectIdRow{}
	for rows.Next() {
		var i GetGeometriesByProjectIdRow
		if err := rows.Scan(
			&i.ID,
			&i.GeoType,
			&i.DrawGeometry,
			&i.Binding,
			&i.TimeStart,
			&i.TimeEnd,
			&i.ProjectID,
			&i.MinLng,
			&i.MinLat,
			&i.MaxLng,
			&i.MaxLat,
			&i.IsDeleted,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const getGeometryById = `-- name: GetGeometryById :one
SELECT id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
    ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
    is_deleted, created_at, updated_at
FROM geometries
WHERE id = $1 AND is_deleted = false
`

type GetGeometryByIdRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) GetGeometryById(ctx context.Context, id pgtype.UUID) (GetGeometryByIdRow, error) {
	row := q.db.QueryRow(ctx, getGeometryById, id)
	var i GetGeometryByIdRow
	err := row.Scan(
		&i.ID,
		&i.GeoType,
		&i.DrawGeometry,
		&i.Binding,
		&i.TimeStart,
		&i.TimeEnd,
		&i.ProjectID,
		&i.MinLng,
		&i.MinLat,
		&i.MaxLng,
		&i.MaxLat,
		&i.IsDeleted,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const searchGeometries = `-- name: SearchGeometries :many
SELECT 
    g.id, g.geo_type, g.draw_geometry, g.binding, g.time_start, g.time_end, g.project_id,
    ST_XMin(g.bbox)::float8 as min_lng, 
    ST_YMin(g.bbox)::float8 as min_lat, 
    ST_XMax(g.bbox)::float8 as max_lng, 
    ST_YMax(g.bbox)::float8 as max_lat,
    g.is_deleted, g.created_at, g.updated_at
FROM geometries g
WHERE g.is_deleted = false
  AND ($1::uuid IS NULL OR g.project_id = $1::uuid)
  AND (
    $2::float8 IS NULL OR
    $3::float8 IS NULL OR
    $4::float8 IS NULL OR
    $5::float8 IS NULL OR
    g.bbox && ST_MakeEnvelope(
        $2::float8, 
        $3::float8, 
        $4::float8, 
        $5::float8, 
        4326
    )
  )
  AND (
    $6::int IS NULL OR
    int4range(g.time_start, g.time_end, '[]') && int4range(
        $6::int - COALESCE($7::int, 0),
        $6::int + COALESCE($7::int, 0),
        '[]'
    )
  )
  AND (
    $8::uuid IS NULL OR
    EXISTS (
        SELECT 1 
        FROM entity_geometries eg 
        WHERE eg.geometry_id = g.id 
          AND eg.entity_id = $8::uuid
    )
  )
ORDER BY g.id DESC
`

type SearchGeometriesParams struct {
	ProjectID    pgtype.UUID   `json:"project_id"`
	SearchMinLng pgtype.Float8 `json:"search_min_lng"`
	SearchMinLat pgtype.Float8 `json:"search_min_lat"`
	SearchMaxLng pgtype.Float8 `json:"search_max_lng"`
	SearchMaxLat pgtype.Float8 `json:"search_max_lat"`
	TimePoint    pgtype.Int4   `json:"time_point"`
	TimeRange    pgtype.Int4   `json:"time_range"`
	EntityID     pgtype.UUID   `json:"entity_id"`
}

type SearchGeometriesRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) SearchGeometries(ctx context.Context, arg SearchGeometriesParams) ([]SearchGeometriesRow, error) {
	rows, err := q.db.Query(ctx, searchGeometries,
		arg.ProjectID,
		arg.SearchMinLng,
		arg.SearchMinLat,
		arg.SearchMaxLng,
		arg.SearchMaxLat,
		arg.TimePoint,
		arg.TimeRange,
		arg.EntityID,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []SearchGeometriesRow{}
	for rows.Next() {
		var i SearchGeometriesRow
		if err := rows.Scan(
			&i.ID,
			&i.GeoType,
			&i.DrawGeometry,
			&i.Binding,
			&i.TimeStart,
			&i.TimeEnd,
			&i.ProjectID,
			&i.MinLng,
			&i.MinLat,
			&i.MaxLng,
			&i.MaxLat,
			&i.IsDeleted,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const searchGeometriesByEntityName = `-- name: SearchGeometriesByEntityName :many
WITH matched_entities AS (
    SELECT
        e.id,
        e.name,
        e.description
    FROM entities e
    WHERE e.is_deleted = false
      AND ($1::text IS NULL OR e.name ILIKE '%' || $1::text || '%')
      AND ($2::uuid IS NULL OR e.id < $2::uuid)
    ORDER BY e.id DESC
    LIMIT $3
)
SELECT
    me.id AS entity_id,
    me.name AS entity_name,
    me.description AS entity_description,
    g.id AS geometry_id,
    g.geo_type,
    g.draw_geometry,
    g.binding,
    g.time_start,
    g.time_end
FROM matched_entities me
LEFT JOIN entity_geometries eg
    ON eg.entity_id = me.id
LEFT JOIN geometries g
    ON g.id = eg.geometry_id
   AND g.is_deleted = false
ORDER BY me.id DESC, g.id DESC
`

type SearchGeometriesByEntityNameParams struct {
	Name       pgtype.Text `json:"name"`
	CursorID   pgtype.UUID `json:"cursor_id"`
	LimitCount int32       `json:"limit_count"`
}

type SearchGeometriesByEntityNameRow struct {
	EntityID          pgtype.UUID `json:"entity_id"`
	EntityName        string      `json:"entity_name"`
	EntityDescription pgtype.Text `json:"entity_description"`
	GeometryID        pgtype.UUID `json:"geometry_id"`
	GeoType           pgtype.Int2 `json:"geo_type"`
	DrawGeometry      []byte      `json:"draw_geometry"`
	Binding           []byte      `json:"binding"`
	TimeStart         pgtype.Int4 `json:"time_start"`
	TimeEnd           pgtype.Int4 `json:"time_end"`
}

func (q *Queries) SearchGeometriesByEntityName(ctx context.Context, arg SearchGeometriesByEntityNameParams) ([]SearchGeometriesByEntityNameRow, error) {
	rows, err := q.db.Query(ctx, searchGeometriesByEntityName, arg.Name, arg.CursorID, arg.LimitCount)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []SearchGeometriesByEntityNameRow{}
	for rows.Next() {
		var i SearchGeometriesByEntityNameRow
		if err := rows.Scan(
			&i.EntityID,
			&i.EntityName,
			&i.EntityDescription,
			&i.GeometryID,
			&i.GeoType,
			&i.DrawGeometry,
			&i.Binding,
			&i.TimeStart,
			&i.TimeEnd,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const updateGeometry = `-- name: UpdateGeometry :one
UPDATE geometries
SET 
    geo_type = COALESCE($1, geo_type),
    draw_geometry = COALESCE($2, draw_geometry),
    binding = COALESCE($3, binding),
    time_start = COALESCE($4, time_start),
    time_end = COALESCE($5, time_end),
    project_id = COALESCE($6, project_id),
    bbox = CASE 
        WHEN $7::boolean = true THEN 
            ST_MakeEnvelope($8::float8, $9::float8, $10::float8, $11::float8, 4326)
        ELSE bbox 
    END,
    updated_at = now()
WHERE id = $12 AND is_deleted = false
RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
    ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
    is_deleted, created_at, updated_at
`

type UpdateGeometryParams struct {
	GeoType      pgtype.Int2   `json:"geo_type"`
	DrawGeometry []byte        `json:"draw_geometry"`
	Binding      []byte        `json:"binding"`
	TimeStart    pgtype.Int4   `json:"time_start"`
	TimeEnd      pgtype.Int4   `json:"time_end"`
	ProjectID    pgtype.UUID   `json:"project_id"`
	UpdateBbox   pgtype.Bool   `json:"update_bbox"`
	MinLng       pgtype.Float8 `json:"min_lng"`
	MinLat       pgtype.Float8 `json:"min_lat"`
	MaxLng       pgtype.Float8 `json:"max_lng"`
	MaxLat       pgtype.Float8 `json:"max_lat"`
	ID           pgtype.UUID   `json:"id"`
}

type UpdateGeometryRow struct {
	ID           pgtype.UUID        `json:"id"`
	GeoType      int16              `json:"geo_type"`
	DrawGeometry json.RawMessage    `json:"draw_geometry"`
	Binding      []byte             `json:"binding"`
	TimeStart    pgtype.Int4        `json:"time_start"`
	TimeEnd      pgtype.Int4        `json:"time_end"`
	ProjectID    pgtype.UUID        `json:"project_id"`
	MinLng       float64            `json:"min_lng"`
	MinLat       float64            `json:"min_lat"`
	MaxLng       float64            `json:"max_lng"`
	MaxLat       float64            `json:"max_lat"`
	IsDeleted    bool               `json:"is_deleted"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) UpdateGeometry(ctx context.Context, arg UpdateGeometryParams) (UpdateGeometryRow, error) {
	row := q.db.QueryRow(ctx, updateGeometry,
		arg.GeoType,
		arg.DrawGeometry,
		arg.Binding,
		arg.TimeStart,
		arg.TimeEnd,
		arg.ProjectID,
		arg.UpdateBbox,
		arg.MinLng,
		arg.MinLat,
		arg.MaxLng,
		arg.MaxLat,
		arg.ID,
	)
	var i UpdateGeometryRow
	err := row.Scan(
		&i.ID,
		&i.GeoType,
		&i.DrawGeometry,
		&i.Binding,
		&i.TimeStart,
		&i.TimeEnd,
		&i.ProjectID,
		&i.MinLng,
		&i.MinLat,
		&i.MaxLng,
		&i.MaxLat,
		&i.IsDeleted,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}
