go-vcard icon indicating copy to clipboard operation
go-vcard copied to clipboard

Unable to use Field Geolocation

Open GibMeMyPacket opened this issue 2 years ago • 1 comments

Hello, I cannot get a same result as RFC describes for the Geolocation field!

RFC GEO Example: GEO;TYPE=work:geo:46.772673,-71.282945

My result: GEO;TYPE=work:geo:51.446570\,35.662524

go-vcard escapes the value and there is no way to use the actual chars in value.

The code:

card.Set(
		vcard.FieldGeolocation, &vcard.Field{
			Value: fmt.Sprintf("%f,%f", info.Location.X, info.Location.Y),
			Params: map[string][]string{
				vcard.ParamType: {vcard.TypeWork + ":geo"},
			},
			Group: "",
		},
	)

I was also getting GEO;TYPE=work;51.446570\,35.662524 which is why i used vcard.TypeWork + ":geo" as a value for ParamType

GibMeMyPacket avatar Feb 22 '23 14:02 GibMeMyPacket

#35 should address this:

card.Set(
	vcard.FieldGeolocation, &vcard.Field{
		Value: vcard.FieldValue(fmt.Sprintf("geo:%f,%f", info.Location.X, info.Location.Y)), // set raw value
		Params: map[string][]string{
			vcard.ParamType: {vcard.TypeWork},
		},
		Group: "",
	},
)

(you could also split the two coordinates and call NewFieldValue(x,y), but this would be more hacky I think)

oliverpool avatar Oct 23 '24 19:10 oliverpool

The escaped \, is correct. This was reported and verified as a mistake in the RFC in the errata: https://www.rfc-editor.org/errata/eid3846.

kinbiko avatar Nov 03 '25 08:11 kinbiko

Thanks for checking!

Indeed, , has a special meaning and separates multiple values for a single field. Here, the field has a single value (the URI itself).

emersion avatar Nov 03 '25 22:11 emersion