Skip to content

Commit

Permalink
assign mz:is_alt and src:alt_label properties
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Aug 19, 2024
1 parent f1478ed commit a342053
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions geoparquet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
_ "log/slog"
"net/url"
"os"
"strconv"
Expand Down Expand Up @@ -190,15 +191,33 @@ func (gpq *GeoParquetWriter) Write(ctx context.Context, key string, r io.ReadSee
return 0, fmt.Errorf("Failed to update properties for %s, %w", key, err)
}

body, err = sjson.SetBytes(body, "properties.mz:is_alt", is_alt)

if err != nil {
return 0, fmt.Errorf("Failed to assign mz:is_alt, %w", err)
}

alt_rsp := old_props.Get("src:alt_label")
body, err = sjson.SetBytes(body, "properties.src:alt_label", alt_rsp.String())

if err != nil {
return 0, fmt.Errorf("Failed to assign src:alt_label property, %w", err)
}

if len(gpq.append_properties) > 0 {

for _, rel_path := range gpq.append_properties {

// Because we are deriving this from old_props and not body
// rel_path := strings.Replace(path, "properties.", "", 1)
abs_path := fmt.Sprintf("properties.%s", rel_path)
rsp := gjson.GetBytes(body, abs_path)

if rsp.Exists() {
continue
}

// Remember: This is a "properties" blob so the path
// should be relative
p_rsp := old_props.Get(rel_path)
abs_path := fmt.Sprintf("properties.%s", rel_path)

// See this? We're assign a value even it doesn't exist because if we
// don't then we end up with uneven properties counts and Parquet is sad.
Expand Down

0 comments on commit a342053

Please sign in to comment.