diff pkg/models/cross.go @ 5601:1222b777f51f

Made golint finally happy.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 06 Aug 2022 02:09:57 +0200
parents 4847ac70103a
children 6270951dda28
line wrap: on
line diff
--- a/pkg/models/cross.go	Sat Aug 06 00:46:21 2022 +0200
+++ b/pkg/models/cross.go	Sat Aug 06 02:09:57 2022 +0200
@@ -27,52 +27,72 @@
 )
 
 type (
-	GeoJSONFeature        string
+	// GeoJSONFeature is a GeoJSON feature.
+	GeoJSONFeature string
+	// GeoJSONLineStringType is a GeoJSON line string type.
 	GeoJSONLineStringType string
 
+	// GeoJSONDate is used to represent dates in GeoJSON.
 	GeoJSONDate struct{ time.Time }
 
+	// GeoJSONLineString is used to represent a linestring
+	// as GeoJSON.
 	GeoJSONLineString struct {
 		Type GeoJSONLineStringType `json:"type"`
 	}
 
+	// GeoJSONCoordinate is a lat/lon coordinate in GeoJSON.
 	GeoJSONCoordinate struct {
 		Lat float64
 		Lon float64
 	}
 
+	// GeoJSONCoordinateZ is a lat/lon coordinate with a z value.
 	GeoJSONCoordinateZ struct {
 		Lat float64
 		Lon float64
 		Z   float64
 	}
 
+	// CrossSectionInputProperties models the input
+	// parameters for a cross section.
 	CrossSectionInputProperties struct {
 		Bottleneck string      `json:"bottleneck"`
 		Date       GeoJSONDate `json:"date"`
 	}
 
-	GeoJSONLineCoordinates  []GeoJSONCoordinate
+	// GeoJSONLineCoordinates is a list of lat/lon coordinates.
+	GeoJSONLineCoordinates []GeoJSONCoordinate
+	// GeoJSONLineCoordinatesZ is a list of lat/lon/z coordinates.
 	GeoJSONLineCoordinatesZ []GeoJSONCoordinateZ
 
+	// GeoJSONMultiLineCoordinatesZ is a list of list of lat/lon/z coords.
 	GeoJSONMultiLineCoordinatesZ []GeoJSONLineCoordinatesZ
 
+	// CrossSectionInputGeometry models the input geometry
+	// of a cross section.
 	CrossSectionInputGeometry struct {
 		Type        GeoJSONLineStringType  `json:"type"`
 		Coordinates GeoJSONLineCoordinates `json:"coordinates"`
 	}
 
+	// CrossSectionInput is combination of geometry and
+	// attributes of a cross section input.
 	CrossSectionInput struct {
 		Type       GeoJSONFeature              `json:"type"`
 		Geometry   CrossSectionInputGeometry   `json:"geometry"`
 		Properties CrossSectionInputProperties `json:"properties"`
 	}
 
+	// CrossSectionOutputGeometry is the geometry part of
+	// the cross section output.
 	CrossSectionOutputGeometry struct {
 		Type        string                       `json:"type"`
 		Coordinates GeoJSONMultiLineCoordinatesZ `json:"coordinates"`
 	}
 
+	// CrossSectionOutput is the combination of the geometry
+	// and the properties of a cross section output.
 	CrossSectionOutput struct {
 		Type       string                     `json:"type"`
 		Geometry   CrossSectionOutputGeometry `json:"geometry"`
@@ -87,6 +107,7 @@
 	errTooLessCoordinates      = errors.New("too less coordinates")
 )
 
+// UnmarshalJSON implements the json.Unmarshaler interface.
 func (lc *GeoJSONLineCoordinates) UnmarshalJSON(data []byte) error {
 	var coords []GeoJSONCoordinate
 	if err := json.Unmarshal(data, &coords); err != nil {
@@ -99,6 +120,7 @@
 	return nil
 }
 
+// UnmarshalJSON implements the json.Unmarshaler interface.
 func (d *GeoJSONDate) UnmarshalJSON(data []byte) error {
 	var s string
 	if err := json.Unmarshal(data, &s); err != nil {
@@ -112,6 +134,7 @@
 	return nil
 }
 
+// UnmarshalJSON implements the json.Unmarshaler interface.
 func (c *GeoJSONCoordinate) UnmarshalJSON(data []byte) error {
 	var pos []float64
 	if err := json.Unmarshal(data, &pos); err != nil {
@@ -124,6 +147,7 @@
 	return nil
 }
 
+// UnmarshalJSON implements the json.Unmarshaler interface.
 func (t *GeoJSONFeature) UnmarshalJSON(data []byte) error {
 	var s string
 	if err := json.Unmarshal(data, &s); err != nil {
@@ -136,6 +160,7 @@
 	return nil
 }
 
+// UnmarshalJSON implements the json.Unmarshaler interface.
 func (t *GeoJSONLineStringType) UnmarshalJSON(data []byte) error {
 	var s string
 	if err := json.Unmarshal(data, &s); err != nil {
@@ -148,6 +173,7 @@
 	return nil
 }
 
+// AsWKB serializes a line string as WKB.
 func (lc GeoJSONLineCoordinates) AsWKB() []byte {
 
 	size := 1 + 4 + 4 + len(lc)*(2*8)
@@ -167,12 +193,14 @@
 	return buf.Bytes()
 }
 
+// MarshalJSON implements ths json.Marshaler interface.
 func (cz GeoJSONCoordinateZ) MarshalJSON() ([]byte, error) {
 	var buf bytes.Buffer
 	fmt.Fprintf(&buf, "[%.8f,%.8f,%.8f]", cz.Lat, cz.Lon, cz.Z)
 	return buf.Bytes(), nil
 }
 
+// Scan implements sql.Scanner interface.
 func (lcz *GeoJSONLineCoordinatesZ) Scan(src interface{}) error {
 	data, ok := src.([]byte)
 	if !ok {
@@ -181,6 +209,7 @@
 	return lcz.FromWKB(data)
 }
 
+// FromWKB deserializes a line string from WKB.
 func (lcz *GeoJSONLineCoordinatesZ) FromWKB(data []byte) error {
 
 	r := bytes.NewReader(data)
@@ -231,6 +260,7 @@
 	return nil
 }
 
+// Equals checks if two coordinates are equal.
 func (cz GeoJSONCoordinateZ) Equals(other GeoJSONCoordinateZ) bool {
 	const (
 		xyEps = 1e-7
@@ -243,6 +273,7 @@
 
 func deg2rad(d float64) float64 { return d * math.Pi / 180.0 }
 
+// Distance calculates the spherical distance between two coords.
 func (cz GeoJSONCoordinateZ) Distance(other GeoJSONCoordinateZ) float64 {
 
 	const EarthRadius = 6378137.0
@@ -258,6 +289,7 @@
 	return math.Sqrt(dLat*dLat+x*x) * EarthRadius
 }
 
+// FromWKB deserializes a line strinf from WKB.
 func (mls *GeoJSONMultiLineCoordinatesZ) FromWKB(data []byte) error {
 	r := bytes.NewReader(data)
 
@@ -345,6 +377,7 @@
 	return nil
 }
 
+// Scan implements the sql.Scanner interface.
 func (mls *GeoJSONMultiLineCoordinatesZ) Scan(src interface{}) error {
 	if src == nil {
 		return nil