diff --git a/client/conn.go b/client/conn.go index 2a0a164b..bf2a447e 100644 --- a/client/conn.go +++ b/client/conn.go @@ -21,13 +21,14 @@ const LiveJSON = `{"ok":true,"live":true}` // MaxMessageSize is maximum accepted message size const MaxMessageSize = 0x1FFFFFFF // 536,870,911 bytes +// Proto is the protocol value. type Proto int const ( - Native Proto = 0 - Telnet Proto = 1 - HTTP Proto = 2 - WebSocket Proto = 3 + Native Proto = 0 // native protocol + Telnet Proto = 1 // telnet protocol + HTTP Proto = 2 // http protocol + WebSocket Proto = 3 // websocket protocol ) // Conn represents a connection to a tile38 server. @@ -67,12 +68,17 @@ func (conn *Conn) Close() error { return conn.pool.put(conn) } +// SetDeadline sets the connection deadline for reads and writes. func (conn *Conn) SetDeadline(t time.Time) error { return conn.c.SetDeadline(t) } + +// SetDeadline sets the connection deadline for reads. func (conn *Conn) SetReadDeadline(t time.Time) error { return conn.c.SetReadDeadline(t) } + +// SetDeadline sets the connection deadline for writes. func (conn *Conn) SetWriteDeadline(t time.Time) error { return conn.c.SetWriteDeadline(t) } @@ -123,6 +129,7 @@ func WriteMessage(w io.Writer, message []byte) error { return err } +// WriteHTTP writes an http message to the connection and closes the connection. func WriteHTTP(conn net.Conn, data []byte) error { var buf bytes.Buffer buf.WriteString("HTTP/1.1 200 OK\r\n") @@ -136,6 +143,7 @@ func WriteHTTP(conn net.Conn, data []byte) error { return err } +// WriteWebSocket writes a websocket message. func WriteWebSocket(conn net.Conn, data []byte) error { var msg []byte buf := make([]byte, 10+len(data)) @@ -179,6 +187,8 @@ func readMessage(wr io.Writer, rd *bufio.Reader) (message []byte, proto Proto, a return message, proto, auth, nil } + +// ReadMessage read the next message from a bufio Reader. func ReadMessage(rd *bufio.Reader, wr io.Writer) (message []byte, proto Proto, auth string, err error) { return readMessage(wr, rd) } diff --git a/client/helper.go b/client/helper.go index 6aa14b84..c60ca465 100644 --- a/client/helper.go +++ b/client/helper.go @@ -12,7 +12,7 @@ type Standard struct { Elapsed string `json:"elapsed"` } -// Server represents tile38 server statistics. +// ServerStats represents tile38 server statistics. type ServerStats struct { Standard Stats struct { @@ -29,7 +29,7 @@ type ServerStats struct { } `json:"stats"` } -// Stats returns tile38 server statistics. +// Server returns tile38 server statistics. func (conn *Conn) Server() (ServerStats, error) { var stats ServerStats msg, err := conn.Do("server") diff --git a/cmd/tile38-cli/kml.go b/cmd/tile38-cli/kml.go index eaeb4647..2ac2fdaf 100644 --- a/cmd/tile38-cli/kml.go +++ b/cmd/tile38-cli/kml.go @@ -12,18 +12,22 @@ type pointT struct { point geojson.SimplePoint } +// KML represents a KML object. type KML struct { points []pointT } +// NewKML returns a new KML object. func NewKML() *KML { return &KML{} } +// AddPoint adds a point to a KML object. func (kml *KML) AddPoint(name string, lat, lon float64) { kml.points = append(kml.points, pointT{name: name, point: geojson.SimplePoint{X: lon, Y: lat}}) } +// Bytes returns the xml of the KML. func (kml *KML) Bytes() []byte { var buf bytes.Buffer buf.WriteString(`` + "\n") diff --git a/cmd/tile38-cli/main.go b/cmd/tile38-cli/main.go index 35b18392..9c9f9be2 100644 --- a/cmd/tile38-cli/main.go +++ b/cmd/tile38-cli/main.go @@ -358,9 +358,8 @@ func convert2termrespval(v resp.Value, spaces int) string { case resp.BulkString: if v.IsNull() { return "(nil)" - } else { - return "\"" + v.String() + "\"" } + return "\"" + v.String() + "\"" case resp.Integer: return "(integer) " + v.String() case resp.Error: diff --git a/controller/aof.go b/controller/aof.go index d57e9c9e..e187562b 100644 --- a/controller/aof.go +++ b/controller/aof.go @@ -16,6 +16,7 @@ import ( "github.com/tidwall/tile38/controller/server" ) +// AsyncHooks indicates that the hooks should happen in the background. const AsyncHooks = true type errAOFHook struct { diff --git a/controller/aofmigrate.go b/controller/aofmigrate.go index f8fc7d8f..40f52e14 100644 --- a/controller/aofmigrate.go +++ b/controller/aofmigrate.go @@ -15,6 +15,7 @@ import ( var errCorruptedAOF = errors.New("corrupted aof file") +// LegacyAOFReader represents the older AOF file reader. type LegacyAOFReader struct { r io.Reader // reader rerr error // read error @@ -24,6 +25,7 @@ type LegacyAOFReader struct { p int // pointer } +// ReadCommand reads an old command. func (rd *LegacyAOFReader) ReadCommand() ([]byte, error) { if rd.l >= 4 { sz1 := int(binary.LittleEndian.Uint32(rd.buf[rd.p:])) @@ -75,6 +77,7 @@ func (rd *LegacyAOFReader) ReadCommand() ([]byte, error) { return rd.ReadCommand() } +// NewLegacyAOFReader creates a new LegacyAOFReader. func NewLegacyAOFReader(r io.Reader) *LegacyAOFReader { rd := &LegacyAOFReader{r: r, chunk: make([]byte, 0xFFFF)} return rd diff --git a/controller/aofshrink.go b/controller/aofshrink.go index 7a84b959..07ee3ebb 100644 --- a/controller/aofshrink.go +++ b/controller/aofshrink.go @@ -116,7 +116,7 @@ func (c *Controller) aofshrink() { } c.aofsz = int(n) // kill all followers connections - for conn, _ := range c.aofconnM { + for conn := range c.aofconnM { conn.Close() } }() diff --git a/controller/bing/bing.go b/controller/bing/bing.go index 1631c250..b8f1f01f 100644 --- a/controller/bing/bing.go +++ b/controller/bing/bing.go @@ -5,13 +5,13 @@ package bing import "math" const ( - EarthRadius = 6378137.0 - MinLatitude = -85.05112878 - MaxLatitude = 85.05112878 - MinLongitude = -180.0 - MaxLongitude = 180.0 - TileSize = 256 - MaxLevelOfDetail = 38 + EarthRadius = 6378137.0 // The radius of the earth + MinLatitude = -85.05112878 // The min lat + MaxLatitude = 85.05112878 // The max lat + MinLongitude = -180.0 // The min lon + MaxLongitude = 180.0 // The max lon + TileSize = 256 // The size of a tile + MaxLevelOfDetail = 38 // The max level of detail ) // Clips a number to the specified minimum and maximum values. @@ -29,7 +29,7 @@ func clip(n, minValue, maxValue float64) float64 { return n } -// Determines the map width and height (in pixels) at a specified level of detail. +// MapSize determines the map width and height (in pixels) at a specified level of detail. // Param 'levelOfDetail' is the level of detail, from 1 (lowest detail) to N (highest detail). // Returns the map width and height in pixels. func MapSize(levelOfDetail uint64) uint64 { @@ -54,7 +54,7 @@ func MapSize(levelOfDetail uint64) uint64 { // return GroundResolution(latitude, levelOfDetail) * float64(screenDpi) / 0.0254 // } -// Converts a point from latitude/longitude WGS-84 coordinates (in degrees) into pixel XY coordinates at a specified level of detail. +// LatLongToPixelXY converts a point from latitude/longitude WGS-84 coordinates (in degrees) into pixel XY coordinates at a specified level of detail. // Param 'latitude' is the latitude of the point, in degrees. // Param 'longitude' is the longitude of the point, in degrees. // Param 'levelOfDetail' is the level of detail, from 1 (lowest detail) to N (highest detail). @@ -72,7 +72,7 @@ func LatLongToPixelXY(latitude, longitude float64, levelOfDetail uint64) (pixelX return } -// Converts a pixel from pixel XY coordinates at a specified level of detail into latitude/longitude WGS-84 coordinates (in degrees). +// PixelXYToLatLong converts a pixel from pixel XY coordinates at a specified level of detail into latitude/longitude WGS-84 coordinates (in degrees). // Param 'pixelX' is the X coordinate of the point, in pixels. // Param 'pixelY' is the Y coordinates of the point, in pixels. // Param 'levelOfDetail' is the level of detail, from 1 (lowest detail) to N (highest detail). @@ -87,7 +87,7 @@ func PixelXYToLatLong(pixelX, pixelY int64, levelOfDetail uint64) (latitude, lon return } -// Converts pixel XY coordinates into tile XY coordinates of the tile containing the specified pixel. +// PixelXYToTileXY converts pixel XY coordinates into tile XY coordinates of the tile containing the specified pixel. // Param 'pixelX' is the pixel X coordinate. // Param 'pixelY' is the pixel Y coordinate. // Return value 'tileX' is the output parameter receiving the tile X coordinate. @@ -96,7 +96,7 @@ func PixelXYToTileXY(pixelX, pixelY int64) (tileX, tileY int64) { return pixelX >> 8, pixelY >> 8 } -// Converts tile XY coordinates into pixel XY coordinates of the upper-left pixel of the specified tile. +// TileXYToPixelXY converts tile XY coordinates into pixel XY coordinates of the upper-left pixel of the specified tile. // Param 'tileX' is the tile X coordinate. // Param 'tileY' is the tile Y coordinate. // Return value 'pixelX' is the output parameter receiving the pixel X coordinate. @@ -105,7 +105,7 @@ func TileXYToPixelXY(tileX, tileY int64) (pixelX, pixelY int64) { return tileX << 8, tileY << 8 } -/// Converts tile XY coordinates into a QuadKey at a specified level of detail. +/// TileXYToQuadKey converts tile XY coordinates into a QuadKey at a specified level of detail. /// Param 'tileX' is the tile X coordinate. /// Param 'tileY' is the tile Y coordinate. /// Param 'levelOfDetail' is the Level of detail, from 1 (lowest detail) to N (highest detail). @@ -129,7 +129,7 @@ func TileXYToQuadKey(tileX, tileY int64, levelOfDetail uint64) string { return string(quadKey) } -/// Converts a QuadKey into tile XY coordinates. +/// QuadKeyToTileXY converts a QuadKey into tile XY coordinates. /// Param 'quadKey' is the quadKey of the tile. /// Return value 'tileX' is the output parameter receiving the tile X coordinate. /// Return value 'tileY is the output parameter receiving the tile Y coordinate. diff --git a/controller/bing/ext.go b/controller/bing/ext.go index a5c72ee5..af2f02f5 100644 --- a/controller/bing/ext.go +++ b/controller/bing/ext.go @@ -2,6 +2,7 @@ package bing import "errors" +// LatLongToQuad iterates through all of the quads parts until levelOfDetail is reached. func LatLongToQuad(latitude, longitude float64, levelOfDetail uint64, iterator func(part int) bool) { pixelX, pixelY := LatLongToPixelXY(latitude, longitude, levelOfDetail) tileX, tileY := PixelXYToTileXY(pixelX, pixelY) @@ -17,16 +18,15 @@ func partForTileXY(tileX, tileY int64, levelOfDetail uint64) int { if (tileX & mask) != 0 { if (tileY & mask) != 0 { return 3 - } else { - return 1 } + return 1 } else if (tileY & mask) != 0 { return 2 - } else { - return 0 } + return 0 } +// TileXYToBounds returns the bounds around a tile. func TileXYToBounds(tileX, tileY int64, levelOfDetail uint64) (minLat, minLon, maxLat, maxLon float64) { size := int64(1 << levelOfDetail) pixelX, pixelY := TileXYToPixelXY(tileX, tileY) @@ -48,6 +48,7 @@ func TileXYToBounds(tileX, tileY int64, levelOfDetail uint64) (minLat, minLon, m return } +// QuadKeyToBounds convers a quadkey to bounds func QuadKeyToBounds(quadkey string) (minLat, minLon, maxLat, maxLon float64, err error) { for i := 0; i < len(quadkey); i++ { switch quadkey[i] { diff --git a/controller/client.go b/controller/client.go index 6a3c1071..561b70bd 100644 --- a/controller/client.go +++ b/controller/client.go @@ -7,12 +7,14 @@ import ( "github.com/tidwall/resp" ) +// Conn represents a simple resp connection. type Conn struct { conn net.Conn rd *resp.Reader wr *resp.Writer } +// DialTimeout dials a resp server. func DialTimeout(address string, timeout time.Duration) (*Conn, error) { tcpconn, err := net.DialTimeout("tcp", address, timeout) if err != nil { @@ -26,11 +28,13 @@ func DialTimeout(address string, timeout time.Duration) (*Conn, error) { return conn, nil } +// Close closes the connection. func (conn *Conn) Close() error { conn.wr.WriteMultiBulk("quit") return conn.conn.Close() } +// Do performs a command and returns a resp value. func (conn *Conn) Do(commandName string, args ...interface{}) (val resp.Value, err error) { if err := conn.wr.WriteMultiBulk(commandName, args...); err != nil { return val, err diff --git a/controller/controller.go b/controller/controller.go index b68bd6c2..e777ca53 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -232,10 +232,9 @@ func (c *Controller) handleInputCommand(conn *server.Conn, msg *server.Message, case server.RESP: if err == errInvalidNumberOfArguments { return writeOutput("-ERR wrong number of arguments for '" + msg.Command + "' command\r\n") - } else { - v, _ := resp.ErrorValue(errors.New("ERR " + err.Error())).MarshalRESP() - return writeOutput(string(v)) } + v, _ := resp.ErrorValue(errors.New("ERR " + err.Error())).MarshalRESP() + return writeOutput(string(v)) } return nil } diff --git a/controller/fence.go b/controller/fence.go index f99574f9..a13a4d3b 100644 --- a/controller/fence.go +++ b/controller/fence.go @@ -9,6 +9,7 @@ import ( var tmfmt = "2006-01-02T15:04:05.999999999Z07:00" +// FenceMatch executes a fence match returns back json messages for fence detection. func FenceMatch(hookName string, sw *scanWriter, fence *liveFenceSwitches, details *commandDetailsT) []string { jshookName := jsonString(hookName) jstime := jsonString(details.timestamp.Format(tmfmt)) @@ -137,21 +138,19 @@ func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool { } else if fence.cmd == "within" { if fence.o != nil { return obj.Within(fence.o) - } else { - return obj.WithinBBox(geojson.BBox{ - Min: geojson.Position{X: fence.minLon, Y: fence.minLat, Z: 0}, - Max: geojson.Position{X: fence.maxLon, Y: fence.maxLat, Z: 0}, - }) } + return obj.WithinBBox(geojson.BBox{ + Min: geojson.Position{X: fence.minLon, Y: fence.minLat, Z: 0}, + Max: geojson.Position{X: fence.maxLon, Y: fence.maxLat, Z: 0}, + }) } else if fence.cmd == "intersects" { if fence.o != nil { return obj.Intersects(fence.o) - } else { - return obj.IntersectsBBox(geojson.BBox{ - Min: geojson.Position{X: fence.minLon, Y: fence.minLat, Z: 0}, - Max: geojson.Position{X: fence.maxLon, Y: fence.maxLat, Z: 0}, - }) } + return obj.IntersectsBBox(geojson.BBox{ + Min: geojson.Position{X: fence.minLon, Y: fence.minLat, Z: 0}, + Max: geojson.Position{X: fence.maxLon, Y: fence.maxLat, Z: 0}, + }) } return false } diff --git a/controller/hooks.go b/controller/hooks.go index 227787a3..fa9dc660 100644 --- a/controller/hooks.go +++ b/controller/hooks.go @@ -14,13 +14,15 @@ import ( "github.com/tidwall/tile38/controller/server" ) +// EndpointProtocol is the type of protocol that the endpoint represents. type EndpointProtocol string const ( - HTTP = EndpointProtocol("http") - Disque = EndpointProtocol("disque") + HTTP = EndpointProtocol("http") // HTTP + Disque = EndpointProtocol("disque") // Disque ) +// Endpoint represents an endpoint. type Endpoint struct { Protocol EndpointProtocol Original string @@ -34,6 +36,7 @@ type Endpoint struct { } } +// Hook represents a hook. type Hook struct { Key string Name string @@ -43,6 +46,7 @@ type Hook struct { ScanWriter *scanWriter } +// Do performs a hook. func (hook *Hook) Do(details *commandDetailsT) error { var lerrs []error msgs := FenceMatch(hook.Name, hook.ScanWriter, hook.Fence, details) @@ -304,9 +308,8 @@ func (c *Controller) cmdDelHook(msg *server.Message) (res string, d commandDetai case server.RESP: if d.updated { return ":1\r\n", d, nil - } else { - return ":0\r\n", d, nil } + return ":0\r\n", d, nil } return } diff --git a/controller/server/anyreader.go b/controller/server/anyreader.go index 744e4753..cfee1a7a 100644 --- a/controller/server/anyreader.go +++ b/controller/server/anyreader.go @@ -13,8 +13,9 @@ import ( "github.com/tidwall/resp" ) -const TelnetIsJSON = false +const telnetIsJSON = false +// Type is resp type type Type int const ( @@ -27,6 +28,7 @@ const ( JSON ) +// String return a string for type. func (t Type) String() string { switch t { default: @@ -56,6 +58,7 @@ func (err errRESPProtocolError) Error() string { return "Protocol error: " + err.msg } +// Message is a resp message type Message struct { Command string Values []resp.Value @@ -64,12 +67,14 @@ type Message struct { Auth string } +// AnyReaderWriter is resp or native reader writer. type AnyReaderWriter struct { rd *bufio.Reader wr io.Writer ws bool } +// NewAnyReaderWriter returns an AnyReaderWriter object. func NewAnyReaderWriter(rd io.Reader) *AnyReaderWriter { ar := &AnyReaderWriter{} if rd2, ok := rd.(*bufio.Reader); ok { @@ -119,6 +124,7 @@ func (ar *AnyReaderWriter) readcrlfline() (string, error) { } } +// ReadMessage reads the next resp message. func (ar *AnyReaderWriter) ReadMessage() (*Message, error) { b, err := ar.rd.ReadByte() if err != nil { @@ -210,7 +216,7 @@ func (ar *AnyReaderWriter) readMultiBulkMessage() (*Message, error) { if len(values) == 0 { return nil, nil } - if telnet && TelnetIsJSON { + if telnet && telnetIsJSON { return &Message{Command: commandValues(values), Values: values, ConnType: Telnet, OutputType: JSON}, nil } return &Message{Command: commandValues(values), Values: values, ConnType: RESP, OutputType: RESP}, nil diff --git a/controller/server/server.go b/controller/server/server.go index 72a91ef6..e4d82117 100644 --- a/controller/server/server.go +++ b/controller/server/server.go @@ -39,6 +39,7 @@ NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. `) + "\r\n") +// Conn represents a server connection. type Conn struct { net.Conn Authenticated bool @@ -137,6 +138,7 @@ func handleConn( } } +// WriteWebSocketMessage write a websocket message to an io.Writer. func WriteWebSocketMessage(w io.Writer, data []byte) error { var msg []byte buf := make([]byte, 10+len(data)) @@ -160,6 +162,7 @@ func WriteWebSocketMessage(w io.Writer, data []byte) error { return err } +// OKMessage returns a default OK message in JSON or RESP. func OKMessage(msg *Message, start time.Time) string { switch msg.OutputType { case JSON: diff --git a/controller/stats.go b/controller/stats.go index d0e80ca9..99c20dc8 100644 --- a/controller/stats.go +++ b/controller/stats.go @@ -129,7 +129,7 @@ func (c *Controller) cmdServer(msg *server.Message) (res string, err error) { func respValuesSimpleMap(m map[string]interface{}) []resp.Value { var keys []string - for key, _ := range m { + for key := range m { keys = append(keys, key) } sort.Strings(keys) diff --git a/core/commands.go b/core/commands.go index fb8ac178..b4bf3c35 100644 --- a/core/commands.go +++ b/core/commands.go @@ -14,6 +14,7 @@ const ( yellow = "\x1b[33m" ) +// Command represents a Tile38 command. type Command struct { Name string `json:"-"` Summary string `json:"summary"` @@ -24,6 +25,7 @@ type Command struct { DevOnly bool `json:"dev"` } +// String returns a string representation of the command. func (c Command) String() string { var s = c.Name for _, arg := range c.Arguments { @@ -32,6 +34,7 @@ func (c Command) String() string { return s } +// TermOutput returns a string representation of the command suitable for displaying in a terminal. func (c Command) TermOutput(indent string) string { line := c.String() var line1 string @@ -45,11 +48,13 @@ func (c Command) TermOutput(indent string) string { return indent + line1 + "\n" + indent + line2 + "\n" //+ indent + line3 + "\n" } +// EnumArg represents a enum arguments. type EnumArg struct { Name string `json:"name"` Arguments []Argument `json:"arguments"` } +// String returns a string representation of an EnumArg. func (a EnumArg) String() string { var s = a.Name for _, arg := range a.Arguments { @@ -58,6 +63,7 @@ func (a EnumArg) String() string { return s } +// Argument represents a command argument. type Argument struct { Command string `json:"command"` NameAny interface{} `json:"name"` @@ -69,6 +75,7 @@ type Argument struct { EnumArgs []EnumArg `json:"enumargs"` } +// String returns a string representation of an Argument. func (a Argument) String() string { var s string if a.Command != "" { @@ -126,6 +133,7 @@ func parseAnyStringArray(any interface{}) []string { return []string{} } +// NameTypes returns the types and names of an argument as separate arrays. func (a Argument) NameTypes() (names, types []string) { names = parseAnyStringArray(a.NameAny) types = parseAnyStringArray(a.TypeAny) @@ -139,6 +147,7 @@ func (a Argument) NameTypes() (names, types []string) { return } +// Commands is a map of all of the commands. var Commands = func() map[string]Command { var commands map[string]Command if err := json.Unmarshal([]byte(commandsJSON), &commands); err != nil { diff --git a/core/options.go b/core/options.go index 0719e5af..dd67acf3 100644 --- a/core/options.go +++ b/core/options.go @@ -6,4 +6,5 @@ var DevMode = false // ShowDebugMessages allows for log.Debug to print to console. var ShowDebugMessages = false +// ProtectedMode forces Tile38 to default in protected mode. var ProtectedMode = "yes" diff --git a/core/version.go b/core/version.go index 1a85e39e..70a0e018 100644 --- a/core/version.go +++ b/core/version.go @@ -1,7 +1,7 @@ package core var ( - Version = "0.0.0" - BuildTime = "" - GitSHA = "0000000" + Version = "0.0.0" // Placeholder for the version + BuildTime = "" // Placeholder for the build time + GitSHA = "0000000" // Placeholder for the git sha ) diff --git a/geojson/bbox.go b/geojson/bbox.go index b01add8e..b4cd22ed 100644 --- a/geojson/bbox.go +++ b/geojson/bbox.go @@ -139,6 +139,7 @@ func (b BBox) ExternalJSON() string { return `{"sw":` + sw.ExternalJSON() + `,"ne":` + ne.ExternalJSON() + `}` } +// Sparse returns back an evenly distributed number of sub bboxs. func (b BBox) Sparse(amount byte) []BBox { if amount == 0 { return []BBox{b} diff --git a/geojson/geohash/geohash.go b/geojson/geohash/geohash.go index 49dd9bd6..f2ec4d01 100644 --- a/geojson/geohash/geohash.go +++ b/geojson/geohash/geohash.go @@ -72,7 +72,7 @@ func Decode(geohash string) (lat, lon float64, err error) { return (neLat-swLat)/2 + swLat, (neLon-swLon)/2 + swLon, nil } -// Returns SW/NE latitude/longitude bounds of specified geohash. +// Bounds returns SW/NE latitude/longitude bounds of specified geohash. func Bounds(geohash string) (swLat, swLon, neLat, neLon float64, err error) { geohash = strings.ToLower(geohash) var evenBit = true diff --git a/geojson/object.go b/geojson/object.go index 0c826f52..608f9fd5 100644 --- a/geojson/object.go +++ b/geojson/object.go @@ -421,6 +421,7 @@ func intersectsObjectShared(g Object, o Object, pin func(v Polygon) bool, mpin f } } +// CirclePolygon returns a Polygon around the radius. func CirclePolygon(x, y, meters float64, steps int) Polygon { if steps < 3 { steps = 3 diff --git a/geojson/position.go b/geojson/position.go index e5d7194f..47965887 100644 --- a/geojson/position.go +++ b/geojson/position.go @@ -130,7 +130,6 @@ func fillPositionBytes(b []byte, isCordZ bool) (Position, []byte, error) { func (p Position) ExternalJSON() string { if p.Z != 0 { return `{"lat":` + strconv.FormatFloat(p.Y, 'f', -1, 64) + `,"lon":` + strconv.FormatFloat(p.X, 'f', -1, 64) + `,"z":` + strconv.FormatFloat(p.Z, 'f', -1, 64) + `}` - } else { - return `{"lat":` + strconv.FormatFloat(p.Y, 'f', -1, 64) + `,"lon":` + strconv.FormatFloat(p.X, 'f', -1, 64) + `}` } + return `{"lat":` + strconv.FormatFloat(p.Y, 'f', -1, 64) + `,"lon":` + strconv.FormatFloat(p.X, 'f', -1, 64) + `}` }