Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
fix(worker): related data is not correctly handled in prepare-gspatialjp
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Feb 7, 2024
1 parent 486cc68 commit 3bba1ba
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
52 changes: 33 additions & 19 deletions worker/preparegspatialjp/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Command(conf *Config) (err error) {
}

var comment string
var citygmlError, plateauError bool
var citygmlError, plateauError, maxlodError bool
defer func() {
if err != nil {
comment = err.Error()
Expand All @@ -61,7 +61,7 @@ func Command(conf *Config) (err error) {
ctx, cms,
cityItem.GeospatialjpData,
err != nil,
citygmlError, plateauError,
citygmlError, plateauError, maxlodError,
strings.TrimSpace(comment),
); err != nil {
log.Errorfc(ctx, "failed to notify error: %w", err)
Expand All @@ -74,6 +74,7 @@ func Command(conf *Config) (err error) {
if err != nil {
citygmlError = true
plateauError = true
maxlodError = true
return fmt.Errorf("failed to get all feature items: %w", err)
}

Expand Down Expand Up @@ -132,27 +133,27 @@ func Command(conf *Config) (err error) {
plateauResult := <-plateauCh
maxlodResult := <-maxlodCh

if citygmlResult.Err != nil {
citygmlError = true
}

if plateauResult.Err != nil {
plateauError = true
}

if citygmlResult.Err != nil || plateauResult.Err != nil {
err = errors.Join(citygmlResult.Err, plateauResult.Err)
if citygmlResult.Err != nil || plateauResult.Err != nil || maxlodResult.Err != nil {
var errs []error
if citygmlResult.Err != nil {
citygmlError = true
errs = append(errs, fmt.Errorf("CityGMLのマージに失敗しました: %w\n", citygmlResult.Err))
}
if plateauResult.Err != nil {
plateauError = true
errs = append(errs, fmt.Errorf("3D Tiles,MVTのマージに失敗しました: %w\n", plateauResult.Err))
}
if maxlodResult.Err != nil {
maxlodError = true
errs = append(errs, fmt.Errorf("最大LODのマージに失敗しました: %w", maxlodResult.Err))
}
err = errors.Join(errs...)
return err
}

if maxlodResult.Err != nil {
log.Errorfc(ctx, "failed to merge maxlod: %w", maxlodResult.Err)
comment += fmt.Sprintf("\n最大LODのマージ処理に失敗しました。: %s", maxlodResult.Err)
}

var citygmlZipAssetID, plateauZipAssetID, maxlodAssetID, relatedZipAssetID string

if !conf.SkipCityGML {
if !conf.SkipRelated {
var err2 error
relatedZipAssetID, err2 = GetRelatedZipAssetID(ctx, cms, cityItem)
if err2 != nil {
Expand Down Expand Up @@ -267,6 +268,9 @@ func attachAssets(ctx context.Context, c *cms.CMS, cityItem *CityItem, citygmlZi

if maxlodAssetID != "" {
item.MaxLOD = maxlodAssetID
item.MergeMaxLODStatus = &cms.Tag{
Name: "成功",
}
}

if relatedZipAssetID != "" {
Expand All @@ -286,7 +290,7 @@ func attachAssets(ctx context.Context, c *cms.CMS, cityItem *CityItem, citygmlZi
return nil
}

func notifyError(ctx context.Context, c *cms.CMS, cityItemID string, isErr bool, citygmlError, plateauError bool, comment string) error {
func notifyError(ctx context.Context, c *cms.CMS, cityItemID string, isErr bool, citygmlError, plateauError, maxLODError bool, comment string) error {
if comment != "" {
msgPrefix := ""
if isErr {
Expand Down Expand Up @@ -327,6 +331,16 @@ func notifyError(ctx context.Context, c *cms.CMS, cityItemID string, isErr bool,
}
}

if maxLODError {
item.MergeMaxLODStatus = &cms.Tag{
Name: "エラー",
}
} else {
item.MergeMaxLODStatus = &cms.Tag{
Name: "未実行",
}
}

var rawItem cms.Item
cms.Marshal(item, &rawItem)
if rawItem.ID == "" {
Expand Down
1 change: 1 addition & 0 deletions worker/preparegspatialjp/maxlod.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func MergeMaxLOD(ctx context.Context, cms *cms.CMS, cityItem *CityItem, allFeatu
if line, err := b.ReadString('\n'); err != nil { // skip the first line
return "", "", fmt.Errorf("failed to read first line: %w", err)
} else if line == "" || isNumeric(rune(line[0])) {
// the first line shold be header (code,type,maxlod,filename)
return "", "", fmt.Errorf("invalid maxlod data for %s", ft)
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion worker/preparegspatialjp/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type CityItem struct {
Specification string `json:"specification,omitempty" cms:"specification,asset"`
Misc string `json:"misc,omitempty" cms:"misc,asset"`
Year string `json:"year,omitempty" cms:"year,select"`
RelatedDataset string `json:"related,omitempty" cms:"related,reference"`
References map[string]string `json:"references,omitempty" cms:"-"`
RelatedDataset string `json:"related_dataset,omitempty" cms:"related_dataset,reference"`
GeospatialjpIndex string `json:"geospatialjp-index,omitempty" cms:"geospatialjp-index,reference"`
GeospatialjpData string `json:"geospatialjp-data,omitempty" cms:"geospatialjp-data,reference"`
}
Expand Down Expand Up @@ -87,6 +87,7 @@ type GspatialjpItem struct {
MergeCityGMLStatus *cms.Tag `json:"merge_citygml_status" cms:"merge_citygml_status,tag,metadata"`
MergePlateauStatus *cms.Tag `json:"merge_plateau_status" cms:"merge_plateau_status,tag,metadata"`
MergeRelatedStatus *cms.Tag `json:"merge_related_status" cms:"merge_related_status,tag,metadata"`
MergeMaxLODStatus *cms.Tag `json:"merge_maxlod_status" cms:"merge_maxlod_status,tag,metadata"`
}

var reReiwa = regexp.MustCompile(`令和([0-9]+?)年度?`)
Expand Down

0 comments on commit 3bba1ba

Please sign in to comment.