Mercurial > gemma
changeset 5274:31c50d676bb0 wfs-optional-sortby
Merged multi-geoms branch
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 09 Jun 2020 10:10:31 +0200 |
parents | eb79bc545482 (current diff) 41a67619c170 (diff) |
children | 73563c4bba5b |
files | |
diffstat | 6 files changed, 87 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue Mon Jun 08 12:17:57 2020 +0200 +++ b/client/src/components/Pdftool.vue Tue Jun 09 10:10:31 2020 +0200 @@ -70,6 +70,7 @@ type="button" v-if="readyToGenerate" class="btn btn-sm btn-info d-block w-100 mt-2" + :disabled="sourcesLoading > 0" > <translate>Generate PDF</translate> </button> @@ -204,10 +205,20 @@ "selectedSurvey", "bottleneckForPrint" ]), - ...mapState("map", ["isolinesLegendImgDataURL"]), + ...mapState("map", ["isolinesLegendImgDataURL", "openLayersMaps"]), ...mapGetters("map", ["openLayersMap"]), generatePdfLable() { return this.$gettext("Generate PDF"); + }, + sourcesLoading() { + let counter = 0; + this.openLayersMaps.forEach(map => { + let layers = map.getLayers().getArray(); + for (let i = 0; i < layers.length; i++) { + if (layers[i].getSource().loading) counter++; + } + }); + return counter; } }, methods: {
--- a/client/src/components/Search.vue Mon Jun 08 12:17:57 2020 +0200 +++ b/client/src/components/Search.vue Tue Jun 09 10:10:31 2020 +0200 @@ -328,6 +328,10 @@ this.openLayersMap() .getLayer("BOTTLENECKS") .setVisible(true); + this.$store.commit( + "bottlenecks/setBottleneckForPrint", + resultEntry.name + ); } if (resultEntry.type === "rhm") { this.openLayersMap()
--- a/client/src/components/map/MapPopup.vue Mon Jun 08 12:17:57 2020 +0200 +++ b/client/src/components/map/MapPopup.vue Tue Jun 09 10:10:31 2020 +0200 @@ -144,6 +144,7 @@ "identifiedFeatures", "identifiedCoordinates" ]), + ...mapState("bottlenecks", ["selectedBottleneck"]), title() { return this.$gettext("Identified Features"); }, @@ -189,6 +190,10 @@ .getExtent(), zoom: 16 }); + this.$store.commit( + "bottlenecks/setBottleneckForPrint", + this.selectedBottleneck + ); this.close(); }, openGauges(gauge) { @@ -214,6 +219,10 @@ .getExtent(), zoom: 16 }); + this.$store.commit( + "bottlenecks/setBottleneckForPrint", + this.selectedBottleneck + ); this.openFairwayAvailability(); }, openFairwayAvailabilityForStretch(stretch) {
--- a/pkg/imports/fd.go Mon Jun 08 12:17:57 2020 +0200 +++ b/pkg/imports/fd.go Tue Jun 09 10:10:31 2020 +0200 @@ -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]++ }
--- a/pkg/imports/wkb.go Mon Jun 08 12:17:57 2020 +0200 +++ b/pkg/imports/wkb.go Tue Jun 09 10:10:31 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 Mon Jun 08 12:17:57 2020 +0200 +++ b/pkg/imports/wp.go Tue Jun 09 10:10:31 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]++ }