removed unused return value

This commit is contained in:
Josh Baker 2016-12-16 14:02:58 -07:00
parent eab4973c20
commit 19da27b562
12 changed files with 54 additions and 54 deletions

View File

@ -15,32 +15,32 @@ type Feature struct {
idprops string // raw id and properties seperated by a '\0' 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 var g Feature
v := gjson.Get(json, "geometry") v := gjson.Get(json, "geometry")
switch v.Type { switch v.Type {
default: default:
return g, nil, errInvalidGeometryMember return g, errInvalidGeometryMember
case gjson.Null: case gjson.Null:
return g, nil, errGeometryMemberRequired return g, errGeometryMemberRequired
case gjson.JSON: case gjson.JSON:
var err error var err error
g.Geometry, err = objectMap(v.Raw, feat) g.Geometry, err = objectMap(v.Raw, feat)
if err != nil { if err != nil {
return g, nil, err return g, err
} }
} }
var err error var err error
g.BBox, err = fillBBox(json) g.BBox, err = fillBBox(json)
if err != nil { if err != nil {
return g, nil, err return g, err
} }
var propsExists bool var propsExists bool
props := gjson.Get(json, "properties") props := gjson.Get(json, "properties")
switch props.Type { switch props.Type {
default: default:
return g, nil, errInvalidPropertiesMember return g, errInvalidPropertiesMember
case gjson.Null: case gjson.Null:
case gjson.JSON: case gjson.JSON:
propsExists = true propsExists = true
@ -49,7 +49,7 @@ func fillFeatureMap(json string) (Feature, []byte, error) {
if id.Exists() || propsExists { if id.Exists() || propsExists {
g.idprops = makeCompositeRaw(id.Raw, props.Raw) g.idprops = makeCompositeRaw(id.Raw, props.Raw)
} }
return g, nil, err return g, err
} }
// Geohash converts the object to a geohash value. // Geohash converts the object to a geohash value.

View File

@ -13,34 +13,34 @@ type FeatureCollection struct {
BBox *BBox BBox *BBox
} }
func fillFeatureCollectionMap(json string) (FeatureCollection, []byte, error) { func fillFeatureCollectionMap(json string) (FeatureCollection, error) {
var g FeatureCollection var g FeatureCollection
res := gjson.Get(json, "features") res := gjson.Get(json, "features")
switch res.Type { switch res.Type {
default: default:
return g, nil, errInvalidFeaturesMember return g, errInvalidFeaturesMember
case gjson.Null: case gjson.Null:
return g, nil, errFeaturesMemberRequired return g, errFeaturesMemberRequired
case gjson.JSON: case gjson.JSON:
if !resIsArray(res) { if !resIsArray(res) {
return g, nil, errInvalidFeaturesMember return g, errInvalidFeaturesMember
} }
v := res.Array() v := res.Array()
g.Features = make([]Object, len(v)) g.Features = make([]Object, len(v))
for i, res := range v { for i, res := range v {
if res.Type != gjson.JSON { if res.Type != gjson.JSON {
return g, nil, errInvalidFeature return g, errInvalidFeature
} }
o, err := objectMap(res.Raw, fcoll) o, err := objectMap(res.Raw, fcoll)
if err != nil { if err != nil {
return g, nil, err return g, err
} }
g.Features[i] = o g.Features[i] = o
} }
} }
var err error var err error
g.BBox, err = fillBBox(json) g.BBox, err = fillBBox(json)
return g, nil, err return g, err
} }
// Geohash converts the object to a geohash value. // Geohash converts the object to a geohash value.

View File

@ -13,34 +13,34 @@ type GeometryCollection struct {
BBox *BBox BBox *BBox
} }
func fillGeometryCollectionMap(json string) (GeometryCollection, []byte, error) { func fillGeometryCollectionMap(json string) (GeometryCollection, error) {
var g GeometryCollection var g GeometryCollection
res := gjson.Get(json, "geometries") res := gjson.Get(json, "geometries")
switch res.Type { switch res.Type {
default: default:
return g, nil, errInvalidGeometries return g, errInvalidGeometries
case gjson.Null: case gjson.Null:
return g, nil, errGeometriesRequired return g, errGeometriesRequired
case gjson.JSON: case gjson.JSON:
if !resIsArray(res) { if !resIsArray(res) {
return g, nil, errInvalidGeometries return g, errInvalidGeometries
} }
v := res.Array() v := res.Array()
g.Geometries = make([]Object, len(v)) g.Geometries = make([]Object, len(v))
for i, res := range v { for i, res := range v {
if res.Type != gjson.JSON { if res.Type != gjson.JSON {
return g, nil, errInvalidGeometry return g, errInvalidGeometry
} }
o, err := objectMap(res.Raw, gcoll) o, err := objectMap(res.Raw, gcoll)
if err != nil { if err != nil {
return g, nil, err return g, err
} }
g.Geometries[i] = o g.Geometries[i] = o
} }
} }
var err error var err error
g.BBox, err = fillBBox(json) g.BBox, err = fillBBox(json)
return g, nil, err return g, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -9,12 +9,12 @@ import (
func resIsArray(res gjson.Result) bool { func resIsArray(res gjson.Result) bool {
if res.Type == gjson.JSON { if res.Type == gjson.JSON {
for i := 0; i < len(res.Raw); i++ { for i := 0; i < len(res.Raw); i++ {
if res.Raw[i] <= ' ' {
continue
}
if res.Raw[i] == '[' { if res.Raw[i] == '[' {
return true return true
} }
if res.Raw[i] <= ' ' {
continue
}
break break
} }
} }
@ -26,7 +26,7 @@ func resIsArray(res gjson.Result) bool {
//////////////////////////////// ////////////////////////////////
func fillLevel1Map(json string) ( func fillLevel1Map(json string) (
coordinates Position, bbox *BBox, bytesOut []byte, err error, coordinates Position, bbox *BBox, err error,
) { ) {
coords := gjson.Get(json, "coordinates") coords := gjson.Get(json, "coordinates")
switch coords.Type { switch coords.Type {
@ -96,7 +96,7 @@ func level1IsCoordZDefined(coordinates Position, bbox *BBox) bool {
//////////////////////////////// ////////////////////////////////
func fillLevel2Map(json string) ( func fillLevel2Map(json string) (
coordinates []Position, bbox *BBox, bytesOut []byte, err error, coordinates []Position, bbox *BBox, err error,
) { ) {
coords := gjson.Get(json, "coordinates") coords := gjson.Get(json, "coordinates")
switch coords.Type { switch coords.Type {
@ -186,7 +186,7 @@ func level2IsCoordZDefined(coordinates []Position, bbox *BBox) bool {
//////////////////////////////// ////////////////////////////////
func fillLevel3Map(json string) ( func fillLevel3Map(json string) (
coordinates [][]Position, bbox *BBox, bytesOut []byte, err error, coordinates [][]Position, bbox *BBox, err error,
) { ) {
coords := gjson.Get(json, "coordinates") coords := gjson.Get(json, "coordinates")
switch coords.Type { switch coords.Type {
@ -305,7 +305,7 @@ func level3IsCoordZDefined(coordinates [][]Position, bbox *BBox) bool {
//////////////////////////////// ////////////////////////////////
func fillLevel4Map(json string) ( func fillLevel4Map(json string) (
coordinates [][][]Position, bbox *BBox, bytesOut []byte, err error, coordinates [][][]Position, bbox *BBox, err error,
) { ) {
coords := gjson.Get(json, "coordinates") coords := gjson.Get(json, "coordinates")
switch coords.Type { switch coords.Type {

View File

@ -8,7 +8,7 @@ type LineString struct {
BBox *BBox 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 err == nil {
if len(coordinates) < 2 { if len(coordinates) < 2 {
err = errLineStringInvalidCoordinates err = errLineStringInvalidCoordinates
@ -17,7 +17,7 @@ func fillLineString(coordinates []Position, bbox *BBox, b []byte, err error) (Li
return LineString{ return LineString{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -11,7 +11,7 @@ type MultiLineString struct {
BBox *BBox 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 { if err == nil {
for _, coordinates := range coordinates { for _, coordinates := range coordinates {
if len(coordinates) < 2 { if len(coordinates) < 2 {
@ -23,7 +23,7 @@ func fillMultiLineString(coordinates [][]Position, bbox *BBox, b []byte, err err
return MultiLineString{ return MultiLineString{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -11,11 +11,11 @@ type MultiPoint struct {
BBox *BBox 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{ return MultiPoint{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -8,7 +8,7 @@ type MultiPolygon struct {
BBox *BBox 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 { if err == nil {
outer: outer:
for _, ps := range coordinates { for _, ps := range coordinates {
@ -27,7 +27,7 @@ func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, b []byte, err erro
return MultiPolygon{ return MultiPolygon{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -195,23 +195,23 @@ func objectMap(json string, from int) (Object, error) {
default: default:
return nil, fmt.Errorf(fmtErrTypeIsUnknown, typ) return nil, fmt.Errorf(fmtErrTypeIsUnknown, typ)
case "Point": case "Point":
o, _, err = fillSimplePointOrPoint(fillLevel1Map(json)) o, err = fillSimplePointOrPoint(fillLevel1Map(json))
case "MultiPoint": case "MultiPoint":
o, _, err = fillMultiPoint(fillLevel2Map(json)) o, err = fillMultiPoint(fillLevel2Map(json))
case "LineString": case "LineString":
o, _, err = fillLineString(fillLevel2Map(json)) o, err = fillLineString(fillLevel2Map(json))
case "MultiLineString": case "MultiLineString":
o, _, err = fillMultiLineString(fillLevel3Map(json)) o, err = fillMultiLineString(fillLevel3Map(json))
case "Polygon": case "Polygon":
o, _, err = fillPolygon(fillLevel3Map(json)) o, err = fillPolygon(fillLevel3Map(json))
case "MultiPolygon": case "MultiPolygon":
o, _, err = fillMultiPolygon(fillLevel4Map(json)) o, err = fillMultiPolygon(fillLevel4Map(json))
case "GeometryCollection": case "GeometryCollection":
o, _, err = fillGeometryCollectionMap(json) o, err = fillGeometryCollectionMap(json)
case "Feature": case "Feature":
o, _, err = fillFeatureMap(json) o, err = fillFeatureMap(json)
case "FeatureCollection": case "FeatureCollection":
o, _, err = fillFeatureCollectionMap(json) o, err = fillFeatureCollectionMap(json)
} }
return o, err return o, err
} }

View File

@ -12,18 +12,18 @@ type Point struct {
BBox *BBox 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 { 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{ return Point{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -13,7 +13,7 @@ type Polygon struct {
BBox *BBox 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 err == nil {
if len(coordinates) == 0 { if len(coordinates) == 0 {
err = errMustBeALinearRing err = errMustBeALinearRing
@ -30,7 +30,7 @@ func fillPolygon(coordinates [][]Position, bbox *BBox, b []byte, err error) (Pol
return Polygon{ return Polygon{
Coordinates: coordinates, Coordinates: coordinates,
BBox: bbox, BBox: bbox,
}, b, err }, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.

View File

@ -16,8 +16,8 @@ func New2DPoint(x, y float64) SimplePoint {
return SimplePoint{x, y} return SimplePoint{x, y}
} }
func fillSimplePoint(coordinates Position, bbox *BBox, b []byte, err error) (SimplePoint, []byte, error) { func fillSimplePoint(coordinates Position, bbox *BBox, err error) (SimplePoint, error) {
return SimplePoint{X: coordinates.X, Y: coordinates.Y}, b, err return SimplePoint{X: coordinates.X, Y: coordinates.Y}, err
} }
// CalculatedBBox is exterior bbox containing the object. // CalculatedBBox is exterior bbox containing the object.