Skip to content

Commit

Permalink
feat: import geopackage, improve config
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Nov 11, 2024
1 parent e02bb1e commit 762b003
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions config/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ type Extent struct {
}

type Search struct {
// Fields that make up the display name and/or suggestions. These fields can be used as variables in the DisplayNameTemplate and SuggestTemplates.
Fields []string `yaml:"fields,omitempty" json:"fields,omitempty" validate:"required"`

DisplayName string `yaml:"displayName,omitempty" json:"displayName,omitempty" validate:"required"`
// Template that indicates how a search record is displayed. Uses Go text/template syntax to reference fields.
DisplayNameTemplate string `yaml:"displayNameTemplate,omitempty" json:"displayNameTemplate,omitempty" validate:"required"`

Suggest []string `yaml:"suggest,omitempty" json:"suggest,omitempty"`
// One or more optional templates that make up the autosuggestions. Uses Go text/template syntax to reference fields.
SuggestTemplates []string `yaml:"suggestTemplates,omitempty" json:"suggestTemplates,omitempty"`

// Version of the collection used to link to search results
Version int `yaml:"version,omitempty" json:"version,omitempty" default:"1"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/etl/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ collections:
- component_thoroughfarename
- component_postaldescriptor
- component_addressareaname
displayName: "{{ .component_thoroughfarename }} - {{ .component_addressareaname }}"
suggest:
displayNameTemplate: "{{ .component_thoroughfarename }} - {{ .component_addressareaname }}"
suggestTemplates:
- "{{ .component_thoroughfarename }} {{ .component_addressareaname }}"
- "{{ .component_thoroughfarename }}, {{ .component_postaldescriptor }} {{ .component_addressareaname }}"
- id: buildings
6 changes: 3 additions & 3 deletions internal/etl/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func (t Transformer) Transform(records []RawRecord, collection config.GeoSpatial
if err != nil {
return nil, err
}
displayName, err := t.renderTemplate(collection.Search.DisplayName, fieldValuesByName)
displayName, err := t.renderTemplate(collection.Search.DisplayNameTemplate, fieldValuesByName)
if err != nil {
return nil, err
}
suggestions := make([]string, 0, len(collection.Search.Suggest))
for _, suggestTemplate := range collection.Search.Suggest {
suggestions := make([]string, 0, len(collection.Search.SuggestTemplates))
for _, suggestTemplate := range collection.Search.SuggestTemplates {
suggestion, err := t.renderTemplate(suggestTemplate, fieldValuesByName)
if err != nil {
return nil, err
Expand Down

0 comments on commit 762b003

Please sign in to comment.