diff --git a/cmd/tile38-cli/kml.go b/cmd/tile38-cli/kml.go deleted file mode 100644 index 5a116ef9..00000000 --- a/cmd/tile38-cli/kml.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - - "github.com/tidwall/tile38/pkg/geojson" -) - -type pointT struct { - name string - 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") - buf.WriteString(`` + "\n") - buf.WriteString(`` + "\n") - buf.WriteString(` ` + "\n") - buf.WriteString(` ` + "\n") - for _, point := range kml.points { - buf.WriteString(fmt.Sprintf(`#yellow%s%f,%f,0`+"\n", point.name, point.point.X, point.point.Y)) - } - buf.WriteString(`` + "\n") - return buf.Bytes() -} diff --git a/cmd/tile38-cli/main.go b/cmd/tile38-cli/main.go index 2fc61c5e..9e4e87fd 100644 --- a/cmd/tile38-cli/main.go +++ b/cmd/tile38-cli/main.go @@ -45,7 +45,6 @@ var ( output = "json" port = 9851 oneCommand string - tokml bool raw bool noprompt bool tty bool @@ -106,8 +105,6 @@ func parseArgs() bool { switch arg { default: return badArg(arg) - case "-kml": - tokml = true case "--raw": raw = true case "--tty": @@ -293,9 +290,8 @@ func main() { if err != io.EOF { fmt.Fprintln(os.Stderr, err.Error()) return - } else { - fmt.Fprintln(os.Stderr, refusedErrorString(addr)) } + fmt.Fprintln(os.Stderr, refusedErrorString(addr)) } } } else { @@ -359,10 +355,7 @@ func main() { break // break out of prompt and just feed data to screen } if mustOutput { - if tokml { - msg = convert2kml(msg) - fmt.Fprintln(os.Stdout, string(msg)) - } else if output == "resp" { + if output == "resp" { if !raw { msg = convert2termresp(msg) } @@ -449,35 +442,6 @@ func numlen(n int) int { return l } -func convert2kml(msg []byte) []byte { - k := NewKML() - var m map[string]interface{} - if err := json.Unmarshal(msg, &m); err == nil { - if v, ok := m["points"].([]interface{}); ok { - for _, v := range v { - if v, ok := v.(map[string]interface{}); ok { - if v, ok := v["point"].(map[string]interface{}); ok { - var name string - var lat, lon float64 - if v, ok := v["id"].(string); ok { - name = v - } - if v, ok := v["lat"].(float64); ok { - lat = v - } - if v, ok := v["lon"].(float64); ok { - lon = v - } - k.AddPoint(name, lat, lon) - } - } - } - } - return k.Bytes() - } - return []byte(`{"ok":false,"err":"results must contain points"}`) -} - func help(arg string) error { var groupsA []string for group := range groupsM {