# HG changeset patch # User Sascha L. Teichmann # Date 1591696965 -7200 # Node ID c84784486265b6d2a742d95c0b3e055a3b5f2959 # Parent 569aaba23e203ec83c98b5459f3a104a0ea1f6a1# Parent a97e79a0757913d6fd0ac35aad0047679f5383a3 Merged default into multi-geoms branch. diff -r a97e79a07579 -r c84784486265 pkg/imports/fd.go --- a/pkg/imports/fd.go Tue Jun 09 11:16:02 2020 +0200 +++ b/pkg/imports/fd.go Tue Jun 09 12:02:45 2020 +0200 @@ -364,16 +364,33 @@ } else { dateInfo = (*props.HydroSorDat).Time } + + var polys multiPolygonSlice + switch feature.Geometry.Type { case "Polygon": var p polygonSlice if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { return err } + polys = multiPolygonSlice{p} + + case "MultiPolygon": + if err := json.Unmarshal(*feature.Geometry.Coordinates, &polys); err != nil { + return err + } + default: + unsupported[feature.Geometry.Type]++ + continue features + } + + // Store the features. + storePolygons: + for _, p := range polys { var fdid int64 var lat, lon float64 - err = savepoint(func() error { - err := insertStmt.QueryRowContext( + switch err := savepoint(func() error { + return insertStmt.QueryRowContext( ctx, p.asWKB(), epsg, @@ -384,26 +401,24 @@ dateInfo, fd.SourceOrganization, ).Scan(&fdid, &lat, &lon) - return err - }) - switch { + }); { case err == sql.ErrNoRows: outside++ // ignore -> filtered by responsibility area (stretches) - continue features + continue storePolygons case err != nil: feedback.Error(pgxutils.ReadableError{Err: err}.Error()) - continue features + continue storePolygons } // 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++ - default: - unsupported[feature.Geometry.Type]++ } } return nil diff -r a97e79a07579 -r c84784486265 pkg/imports/wkb.go --- a/pkg/imports/wkb.go Tue Jun 09 11:16:02 2020 +0200 +++ b/pkg/imports/wkb.go Tue Jun 09 12:02:45 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{}) { diff -r a97e79a07579 -r c84784486265 pkg/imports/wp.go --- a/pkg/imports/wp.go Tue Jun 09 11:16:02 2020 +0200 +++ b/pkg/imports/wp.go Tue Jun 09 12:02:45 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]++ }