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e~BwkAoqDcfDolLsn@ed@kuAcpDuxAi_Dmn@szCcnFwoNkpDevEmn@_`As}@whCkuDmyLqeAgiDqq@}jAelA{gBkcAmwBmVkkDam@mwBs_Ayx@_[ooAw`A_wDqf@ebDel@akFo_Ai{F_YqoAaBysAdL}qFwGipAhCm|EpHywClWcjAT{n@cn@w{AgcB{_Egq@{j@sYkMai@w_Aiw@_uAwIoO_PkIkF~MmHn@gCiD"
	points, err := polyline.Decode(test, 2)

	if err != nil {
		return
	}

	kml := gokml.NewKML("teste")
	//style := gokml.NewStyle("linestringStyle", 127, 255, 255, 0)
	linestring := gokml.NewLineString()
	placemark := gokml.NewPlacemark("Rota", "route between two points", linestring)
	//placemark.SetStyle("linestringStyle")
	kml.AddFeature(placemark)
	//kml.AddFeature(style)

	for i := 0; i < len(points); i = i + 2 {
		point := gokml.NewPoint(points[i], points[i+1], 0)
		linestring.AddPoint(point)
	}

	kmlString := kml.Render()

	err = ioutil.WriteFile("teste.kml", []byte(kmlString), 0644)
	check(err)

	fmt.Printf("%+v\n", kmlString)
}
Exemplo n.º 2
0
//DecodePolyline decodes given polyline and return coordinates
func DecodePolyline(line string) ([]*Point, error) {
	flatC, err := polyline.Decode(line, 2)
	if err != nil {
		return nil, err
	}
	var coordinates []*Point
	for i := 0; i < len(flatC)/2; i++ {
		point := &Point{Lat: flatC[2*i], Lng: flatC[2*i+1]}
		coordinates = append(coordinates, point)
	}
	return coordinates, nil
}