diff --git a/geojson/feature.go b/geojson/feature.go index bd7a5576..a74f80ce 100644 --- a/geojson/feature.go +++ b/geojson/feature.go @@ -15,32 +15,32 @@ type Feature struct { idprops string // raw id and properties seperated by a '\0' } -func fillFeatureMap(json string) (Feature, []byte, error) { +func fillFeatureMap(json string) (Feature, error) { var g Feature v := gjson.Get(json, "geometry") switch v.Type { default: - return g, nil, errInvalidGeometryMember + return g, errInvalidGeometryMember case gjson.Null: - return g, nil, errGeometryMemberRequired + return g, errGeometryMemberRequired case gjson.JSON: var err error g.Geometry, err = objectMap(v.Raw, feat) if err != nil { - return g, nil, err + return g, err } } var err error g.BBox, err = fillBBox(json) if err != nil { - return g, nil, err + return g, err } var propsExists bool props := gjson.Get(json, "properties") switch props.Type { default: - return g, nil, errInvalidPropertiesMember + return g, errInvalidPropertiesMember case gjson.Null: case gjson.JSON: propsExists = true @@ -49,7 +49,7 @@ func fillFeatureMap(json string) (Feature, []byte, error) { if id.Exists() || propsExists { g.idprops = makeCompositeRaw(id.Raw, props.Raw) } - return g, nil, err + return g, err } // Geohash converts the object to a geohash value. diff --git a/geojson/featurecollection.go b/geojson/featurecollection.go index 51300a19..b46150b1 100644 --- a/geojson/featurecollection.go +++ b/geojson/featurecollection.go @@ -13,34 +13,34 @@ type FeatureCollection struct { BBox *BBox } -func fillFeatureCollectionMap(json string) (FeatureCollection, []byte, error) { +func fillFeatureCollectionMap(json string) (FeatureCollection, error) { var g FeatureCollection res := gjson.Get(json, "features") switch res.Type { default: - return g, nil, errInvalidFeaturesMember + return g, errInvalidFeaturesMember case gjson.Null: - return g, nil, errFeaturesMemberRequired + return g, errFeaturesMemberRequired case gjson.JSON: if !resIsArray(res) { - return g, nil, errInvalidFeaturesMember + return g, errInvalidFeaturesMember } v := res.Array() g.Features = make([]Object, len(v)) for i, res := range v { if res.Type != gjson.JSON { - return g, nil, errInvalidFeature + return g, errInvalidFeature } o, err := objectMap(res.Raw, fcoll) if err != nil { - return g, nil, err + return g, err } g.Features[i] = o } } var err error g.BBox, err = fillBBox(json) - return g, nil, err + return g, err } // Geohash converts the object to a geohash value. diff --git a/geojson/geometrycollection.go b/geojson/geometrycollection.go index 9eeba4c0..f28e0b51 100644 --- a/geojson/geometrycollection.go +++ b/geojson/geometrycollection.go @@ -13,34 +13,34 @@ type GeometryCollection struct { BBox *BBox } -func fillGeometryCollectionMap(json string) (GeometryCollection, []byte, error) { +func fillGeometryCollectionMap(json string) (GeometryCollection, error) { var g GeometryCollection res := gjson.Get(json, "geometries") switch res.Type { default: - return g, nil, errInvalidGeometries + return g, errInvalidGeometries case gjson.Null: - return g, nil, errGeometriesRequired + return g, errGeometriesRequired case gjson.JSON: if !resIsArray(res) { - return g, nil, errInvalidGeometries + return g, errInvalidGeometries } v := res.Array() g.Geometries = make([]Object, len(v)) for i, res := range v { if res.Type != gjson.JSON { - return g, nil, errInvalidGeometry + return g, errInvalidGeometry } o, err := objectMap(res.Raw, gcoll) if err != nil { - return g, nil, err + return g, err } g.Geometries[i] = o } } var err error g.BBox, err = fillBBox(json) - return g, nil, err + return g, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/levels.go b/geojson/levels.go index 8406fcae..d7d3503e 100644 --- a/geojson/levels.go +++ b/geojson/levels.go @@ -9,12 +9,12 @@ import ( func resIsArray(res gjson.Result) bool { if res.Type == gjson.JSON { for i := 0; i < len(res.Raw); i++ { - if res.Raw[i] <= ' ' { - continue - } if res.Raw[i] == '[' { return true } + if res.Raw[i] <= ' ' { + continue + } break } } @@ -26,7 +26,7 @@ func resIsArray(res gjson.Result) bool { //////////////////////////////// func fillLevel1Map(json string) ( - coordinates Position, bbox *BBox, bytesOut []byte, err error, + coordinates Position, bbox *BBox, err error, ) { coords := gjson.Get(json, "coordinates") switch coords.Type { @@ -96,7 +96,7 @@ func level1IsCoordZDefined(coordinates Position, bbox *BBox) bool { //////////////////////////////// func fillLevel2Map(json string) ( - coordinates []Position, bbox *BBox, bytesOut []byte, err error, + coordinates []Position, bbox *BBox, err error, ) { coords := gjson.Get(json, "coordinates") switch coords.Type { @@ -186,7 +186,7 @@ func level2IsCoordZDefined(coordinates []Position, bbox *BBox) bool { //////////////////////////////// func fillLevel3Map(json string) ( - coordinates [][]Position, bbox *BBox, bytesOut []byte, err error, + coordinates [][]Position, bbox *BBox, err error, ) { coords := gjson.Get(json, "coordinates") switch coords.Type { @@ -305,7 +305,7 @@ func level3IsCoordZDefined(coordinates [][]Position, bbox *BBox) bool { //////////////////////////////// func fillLevel4Map(json string) ( - coordinates [][][]Position, bbox *BBox, bytesOut []byte, err error, + coordinates [][][]Position, bbox *BBox, err error, ) { coords := gjson.Get(json, "coordinates") switch coords.Type { diff --git a/geojson/linestring.go b/geojson/linestring.go index 792607b0..533a512c 100644 --- a/geojson/linestring.go +++ b/geojson/linestring.go @@ -8,7 +8,7 @@ type LineString struct { BBox *BBox } -func fillLineString(coordinates []Position, bbox *BBox, b []byte, err error) (LineString, []byte, error) { +func fillLineString(coordinates []Position, bbox *BBox, err error) (LineString, error) { if err == nil { if len(coordinates) < 2 { err = errLineStringInvalidCoordinates @@ -17,7 +17,7 @@ func fillLineString(coordinates []Position, bbox *BBox, b []byte, err error) (Li return LineString{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/multilinestring.go b/geojson/multilinestring.go index c9545725..6c328793 100644 --- a/geojson/multilinestring.go +++ b/geojson/multilinestring.go @@ -11,7 +11,7 @@ type MultiLineString struct { BBox *BBox } -func fillMultiLineString(coordinates [][]Position, bbox *BBox, b []byte, err error) (MultiLineString, []byte, error) { +func fillMultiLineString(coordinates [][]Position, bbox *BBox, err error) (MultiLineString, error) { if err == nil { for _, coordinates := range coordinates { if len(coordinates) < 2 { @@ -23,7 +23,7 @@ func fillMultiLineString(coordinates [][]Position, bbox *BBox, b []byte, err err return MultiLineString{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/multipoint.go b/geojson/multipoint.go index 972ab32b..87f66667 100644 --- a/geojson/multipoint.go +++ b/geojson/multipoint.go @@ -11,11 +11,11 @@ type MultiPoint struct { BBox *BBox } -func fillMultiPoint(coordinates []Position, bbox *BBox, b []byte, err error) (MultiPoint, []byte, error) { +func fillMultiPoint(coordinates []Position, bbox *BBox, err error) (MultiPoint, error) { return MultiPoint{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/multipolygon.go b/geojson/multipolygon.go index aed83356..944570f5 100644 --- a/geojson/multipolygon.go +++ b/geojson/multipolygon.go @@ -8,7 +8,7 @@ type MultiPolygon struct { BBox *BBox } -func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, b []byte, err error) (MultiPolygon, []byte, error) { +func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, err error) (MultiPolygon, error) { if err == nil { outer: for _, ps := range coordinates { @@ -27,7 +27,7 @@ func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, b []byte, err erro return MultiPolygon{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/object.go b/geojson/object.go index 5414b100..3d2e425a 100644 --- a/geojson/object.go +++ b/geojson/object.go @@ -195,23 +195,23 @@ func objectMap(json string, from int) (Object, error) { default: return nil, fmt.Errorf(fmtErrTypeIsUnknown, typ) case "Point": - o, _, err = fillSimplePointOrPoint(fillLevel1Map(json)) + o, err = fillSimplePointOrPoint(fillLevel1Map(json)) case "MultiPoint": - o, _, err = fillMultiPoint(fillLevel2Map(json)) + o, err = fillMultiPoint(fillLevel2Map(json)) case "LineString": - o, _, err = fillLineString(fillLevel2Map(json)) + o, err = fillLineString(fillLevel2Map(json)) case "MultiLineString": - o, _, err = fillMultiLineString(fillLevel3Map(json)) + o, err = fillMultiLineString(fillLevel3Map(json)) case "Polygon": - o, _, err = fillPolygon(fillLevel3Map(json)) + o, err = fillPolygon(fillLevel3Map(json)) case "MultiPolygon": - o, _, err = fillMultiPolygon(fillLevel4Map(json)) + o, err = fillMultiPolygon(fillLevel4Map(json)) case "GeometryCollection": - o, _, err = fillGeometryCollectionMap(json) + o, err = fillGeometryCollectionMap(json) case "Feature": - o, _, err = fillFeatureMap(json) + o, err = fillFeatureMap(json) case "FeatureCollection": - o, _, err = fillFeatureCollectionMap(json) + o, err = fillFeatureCollectionMap(json) } return o, err } diff --git a/geojson/point.go b/geojson/point.go index 91c494b1..5b37e01c 100644 --- a/geojson/point.go +++ b/geojson/point.go @@ -12,18 +12,18 @@ type Point struct { BBox *BBox } -func fillSimplePointOrPoint(coordinates Position, bbox *BBox, b []byte, err error) (Object, []byte, error) { +func fillSimplePointOrPoint(coordinates Position, bbox *BBox, err error) (Object, error) { if coordinates.Z == 0 && bbox == nil { - return fillSimplePoint(coordinates, bbox, b, err) + return fillSimplePoint(coordinates, bbox, err) } - return fillPoint(coordinates, bbox, b, err) + return fillPoint(coordinates, bbox, err) } -func fillPoint(coordinates Position, bbox *BBox, b []byte, err error) (Point, []byte, error) { +func fillPoint(coordinates Position, bbox *BBox, err error) (Point, error) { return Point{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/polygon.go b/geojson/polygon.go index f52b1d7e..8fc3d2fb 100644 --- a/geojson/polygon.go +++ b/geojson/polygon.go @@ -13,7 +13,7 @@ type Polygon struct { BBox *BBox } -func fillPolygon(coordinates [][]Position, bbox *BBox, b []byte, err error) (Polygon, []byte, error) { +func fillPolygon(coordinates [][]Position, bbox *BBox, err error) (Polygon, error) { if err == nil { if len(coordinates) == 0 { err = errMustBeALinearRing @@ -30,7 +30,7 @@ func fillPolygon(coordinates [][]Position, bbox *BBox, b []byte, err error) (Pol return Polygon{ Coordinates: coordinates, BBox: bbox, - }, b, err + }, err } // CalculatedBBox is exterior bbox containing the object. diff --git a/geojson/simplepoint.go b/geojson/simplepoint.go index 7c817cea..f39439ee 100644 --- a/geojson/simplepoint.go +++ b/geojson/simplepoint.go @@ -16,8 +16,8 @@ func New2DPoint(x, y float64) SimplePoint { return SimplePoint{x, y} } -func fillSimplePoint(coordinates Position, bbox *BBox, b []byte, err error) (SimplePoint, []byte, error) { - return SimplePoint{X: coordinates.X, Y: coordinates.Y}, b, err +func fillSimplePoint(coordinates Position, bbox *BBox, err error) (SimplePoint, error) { + return SimplePoint{X: coordinates.X, Y: coordinates.Y}, err } // CalculatedBBox is exterior bbox containing the object.