Mercurial > gemma
changeset 5276:6f56d17c0291
Merged wfs-optional-sortby branch (including multi-geoms branch).
author | Sascha Wilde <sascha.wilde@intevation.de> |
---|---|
date | Thu, 11 Jun 2020 10:06:59 +0200 |
parents | aca4bf7af270 (current diff) 73563c4bba5b (diff) |
children | 3bab0e19f08b |
files | |
diffstat | 11 files changed, 76 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importconfiguration/ScheduledImports.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/ScheduledImports.vue Thu Jun 11 10:06:59 2020 +0200 @@ -473,7 +473,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018, 2019 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH * @@ -611,18 +611,6 @@ return false; } }, - isSortbyRequired() { - switch (this.import_) { - case this.$options.IMPORTTYPES.WATERWAYAXIS: - case this.$options.IMPORTTYPES.WATERWAYAREA: - case this.$options.IMPORTTYPES.FAIRWAYDIMENSION: - case this.$options.IMPORTTYPES.FAIRWAYMARKS: - case this.$options.IMPORTTYPES.DISTANCEMARKSASHORE: - return true; - default: - return false; - } - }, isToleranceRequired() { switch (this.import_) { case this.$options.IMPORTTYPES.BOTTLENECK: @@ -653,7 +641,6 @@ if (this.directImport && !this.uploadFile) return false; else if (!this.directImport) { if (this.isURLRequired && !this.url) return false; - if (this.isSortbyRequired && !this.sortBy) return false; if (this.isFeatureTypeRequired && !this.featureType) return false; if (this.isCredentialsRequired && !this.usernamePasswordFilled) return false; @@ -894,10 +881,6 @@ if (!this.featureType) return; data["feature-type"] = this.featureType; } - if (this.isSortbyRequired) { - if (!this.sortBy) return; - data["sort-by"] = this.sortBy; - } if (this.isToleranceRequired) { if (!this.tolerance) return; data["tolerance"] = parseFloat(this.tolerance); @@ -977,10 +960,6 @@ config["url"] = this.url; config["insecure"] = this.insecure; } - if (this.isSortbyRequired) { - if (!this.sortBy) return; - config["sort-by"] = this.sortBy; - } if (this.isFeatureTypeRequired) { if (!this.featureType) return; config["feature-type"] = this.featureType;
--- a/client/src/components/importconfiguration/types/Distancemarksashore.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/Distancemarksashore.vue Thu Jun 11 10:06:59 2020 +0200 @@ -53,13 +53,6 @@ :value="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> </div> @@ -72,7 +65,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH *
--- a/client/src/components/importconfiguration/types/Fairwaydimensions.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/Fairwaydimensions.vue Thu Jun 11 10:06:59 2020 +0200 @@ -53,13 +53,6 @@ :value="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> <div class="d-flex px-2"> @@ -183,7 +176,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH *
--- a/client/src/components/importconfiguration/types/Fairwaymarks.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/Fairwaymarks.vue Thu Jun 11 10:06:59 2020 +0200 @@ -72,13 +72,6 @@ :value="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> </div> @@ -91,7 +84,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH *
--- a/client/src/components/importconfiguration/types/WaterwayProfiles.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/WaterwayProfiles.vue Thu Jun 11 10:06:59 2020 +0200 @@ -75,13 +75,6 @@ v-model="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> </div> @@ -124,7 +117,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH * @@ -166,7 +159,7 @@ this.uploadFile = files[0]; }, submit() { - if (!this.url || !this.featureType || !this.sortBy || !this.uploadFile) + if (!this.url || !this.featureType || !this.uploadFile) return; let formData = new FormData(); formData.append("wp", this.uploadFile);
--- a/client/src/components/importconfiguration/types/Waterwayarea.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/Waterwayarea.vue Thu Jun 11 10:06:59 2020 +0200 @@ -53,13 +53,6 @@ :value="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> </div> @@ -72,7 +65,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH *
--- a/client/src/components/importconfiguration/types/Waterwayaxis.vue Wed Jun 10 16:33:10 2020 +0200 +++ b/client/src/components/importconfiguration/types/Waterwayaxis.vue Thu Jun 11 10:06:59 2020 +0200 @@ -53,13 +53,6 @@ :value="sortBy" /> </div> - <div v-if="!sortBy" class="d-flex flex-row"> - <small - ><translate class="text-danger" - >Please enter SortBy</translate - ></small - > - </div> </div> </div> </div> @@ -72,7 +65,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * - * Copyright (C) 2018 by via donau + * Copyright (C) 2018, 2019, 2020 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH *
--- a/pkg/imports/fd.go Wed Jun 10 16:33:10 2020 +0200 +++ b/pkg/imports/fd.go Thu Jun 11 10:06:59 2020 +0200 @@ -4,7 +4,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // -// Copyright (C) 2018 by via donau +// Copyright (C) 2018, 2019, 2020 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // @@ -17,6 +17,7 @@ "context" "database/sql" "encoding/json" + "errors" "fmt" "io" "strings" @@ -47,6 +48,8 @@ Password string `json:"password,omitempty"` } +var errContinue = errors.New("continue") + // Description gives a short info about relevant facts of this import. func (fd *FairwayDimension) Description() (string, error) { return strings.Join([]string{ @@ -364,12 +367,10 @@ } else { dateInfo = (*props.HydroSorDat).Time } - switch feature.Geometry.Type { - case "Polygon": - var p polygonSlice - if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { - return err - } + + // Store a feature in the database. + storeFeature := func(p polygonSlice) error { + var fdid int64 var lat, lon float64 err = savepoint(func() error { @@ -390,18 +391,50 @@ case err == sql.ErrNoRows: outside++ // ignore -> filtered by responsibility area (stretches) - continue features + return errContinue case err != nil: feedback.Error(pgxutils.ReadableError{Err: err}.Error()) - continue features + return errContinue } // Store for potential later removal. - if err = track(ctx, tx, importID, "waterway.fairway_dimensions", fdid); err != nil { + if err = track( + ctx, tx, importID, "waterway.fairway_dimensions", fdid, + ); err != nil { return err } fds = append(fds, fdSummary{ID: fdid, Lat: lat, Lon: lon}) features++ + + return nil + } + + switch feature.Geometry.Type { + case "Polygon": + var p polygonSlice + if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { + return err + } + switch err := storeFeature(p); { + case err == errContinue: + continue features + case err != nil: + return err + } + + case "MultiPolygon": + var mp multiPolygonSlice + if err := json.Unmarshal(*feature.Geometry.Coordinates, &mp); err != nil { + return err + } + for i := range mp { + switch err := storeFeature(mp[i]); { + case err == errContinue: + continue features + case err != nil: + return err + } + } default: unsupported[feature.Geometry.Type]++ } @@ -430,6 +463,8 @@ if features == 0 { feedback.Info("No new features found") + } else { + feedback.Info("Stored %d features", features) } // Invalidate features that have been removed from data source @@ -469,7 +504,8 @@ oldID, ).Scan(&fdid, &lat, &lon) }); err != nil { - feedback.Error(pgxutils.ReadableError{Err: err}.Error()) + feedback.Error(pgxutils.ReadableError{Err: err}.Error() + + "- while tracking invalidation of: %d", oldID) continue } fds = append(fds, fdSummary{ID: fdid, Lat: lat, Lon: lon})
--- a/pkg/imports/wkb.go Wed Jun 10 16:33:10 2020 +0200 +++ b/pkg/imports/wkb.go Thu Jun 11 10:06:59 2020 +0200 @@ -25,10 +25,11 @@ ) type ( - pointSlice []float64 - lineSlice [][]float64 - multiLineSlice []lineSlice - polygonSlice [][][]float64 + pointSlice []float64 + lineSlice [][]float64 + multiLineSlice []lineSlice + polygonSlice [][][]float64 + multiPolygonSlice []polygonSlice ) func newPointFeature(newProperties func() interface{}) func() (string, interface{}) {
--- a/pkg/imports/wp.go Wed Jun 10 16:33:10 2020 +0200 +++ b/pkg/imports/wp.go Thu Jun 11 10:06:59 2020 +0200 @@ -298,6 +298,21 @@ return err } features++ + case "MultiLineString": + var ml multiLineSlice + if err := json.Unmarshal(*feature.Geometry.Coordinates, &ml); err != nil { + return err + } + for i := range ml { + if _, err := insertStmt.ExecContext( + ctx, + ml[i].asWKB(), + epsg, + ); err != nil { + return err + } + features++ + } default: unsupported[feature.Geometry.Type]++ }
--- a/pkg/pgxutils/errors.go Wed Jun 10 16:33:10 2020 +0200 +++ b/pkg/pgxutils/errors.go Thu Jun 11 10:06:59 2020 +0200 @@ -135,7 +135,7 @@ case "fairway_dimensions": switch err.ConstraintName { case "fairway_dimensions_area_unique": - m = "Duplicate fairway area" + m = "Duplicate fairway dimension area" c = http.StatusConflict return }