// LatLong returns the latitude and longitude of the photo and
// whether it was present.
168412
func (x *Exif) LatLong() (lat, long float64, err error) {
	// All calls of x.Get might return an TagNotPresentError
	longTag, err := x.Get(FieldName("GPSLongitude"))
	if err != nil {
		return
	}
	ewTag, err := x.Get(FieldName("GPSLongitudeRef"))
	if err != nil {
		return
	}
	latTag, err := x.Get(FieldName("GPSLatitude"))
	if err != nil {
		return
	}
	nsTag, err := x.Get(FieldName("GPSLatitudeRef"))
	if err != nil {
		return
	}
	if long, err = tagDegrees(longTag); err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	if lat, err = tagDegrees(latTag); err != nil {
		return 0, 0, fmt.Errorf("Cannot parse latitude: %v", err)
	}
	ew, err := ewTag.StringVal()
	if err == nil && ew == "W" {
		long *= -1.0
	} else if err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	ns, err := nsTag.StringVal()
	if err == nil && ns == "S" {
		lat *= -1.0
	} else if err != nil {
		return 0, 0, fmt.Errorf("Cannot parse longitude: %v", err)
	}
	return lat, long, nil
}
105548
func (m Map) Find(pos, end int) (Location, bool) {
	key := Location{
		Pos: pos,
		End: end,
	}
	if loc, ok := m[key]; ok {
		return loc, true
	}
	return key, false
}
1238498
func ParseLatLong(s string) (float64, error) {
	var l float64
	if v, err := ParseDMS(s); err == nil {
		l = v
	} else if v, err := ParseGPS(s); err == nil {
		l = v
	} else if v, err := ParseDecimal(s); err == nil {
		l = v
	} else {
		return 0, fmt.Errorf("cannot parse [%s], unknown format", s)
	}
	if l < -180.0 || 180.0 < l {
		return 0, errors.New("coordinate is not in range -180, 180")
	}
	return l, nil
}
892130
func (sp *SendLocation) SetLatitude(lat float64) *SendLocation {
	sp.Latitude = lat
	return sp
}
1239786
func (p *MercatorProjection) ToLatLng(pt r2.Point) LatLng {
	// This formula is more accurate near zero than the atan(exp()) version.
	x := p.toRadians * math.Remainder(pt.X, p.xWrap)
	k := math.Exp(2 * p.toRadians * pt.Y)
	var y float64
	if math.IsInf(k, 0) {
		y = math.Pi / 2
	} else {
		y = math.Asin((k - 1) / (k + 1))
	}
	return LatLng{s1.Angle(y), s1.Angle(x)}
}
546268
func (l *location) String() string {
	if len(l.File) == 0 {
		return ""
	}

	return fmt.Sprintf("%s:%d", l.File, l.Line)
}
635519
function (latlon) {
        return {
            x: latlon.lng * 6378137 * Math.PI / 180,
            y: Math.log(Math.tan((90 + latlon.lat) * Math.PI / 360)) * 6378137
        };
    }
200938
func (s *IndexField) SetLatLonOptions(v *LatLonOptions) *IndexField {
	s.LatLonOptions = v
	return s
}
1298336
func RectFromLatLng(p LatLng) Rect {
	return Rect{
		Lat: r1.Interval{p.Lat.Radians(), p.Lat.Radians()},
		Lng: s1.Interval{p.Lng.Radians(), p.Lng.Radians()},
	}
}
460459
func (r Rect) AddPoint(ll LatLng) Rect {
	if !ll.IsValid() {
		return r
	}
	return Rect{
		Lat: r.Lat.AddPoint(ll.Lat.Radians()),
		Lng: r.Lng.AddPoint(ll.Lng.Radians()),
	}
}
766379
public static boolean contains(LatLong[] latLongs, LatLong latLong) {
        boolean result = false;
        for (int i = 0, j = latLongs.length - 1; i < latLongs.length; j = i++) {
            if ((latLongs[i].latitude > latLong.latitude) != (latLongs[j].latitude > latLong.latitude)
                    && (latLong.longitude < (latLongs[j].longitude - latLongs[i].longitude) * (latLong.latitude - latLongs[i].latitude)
                    / (latLongs[j].latitude - latLongs[i].latitude) + latLongs[i].longitude)) {
                result = !result;
            }
        }
        return result;
    }
1364344
func NewSearchSortGeoDistance(field string, lat, lon float64) *SearchSortGeoDistance {
	q := &SearchSortGeoDistance{newFtsSortBase()}
	q.options["by"] = "geo_distance"
	q.options["field"] = field
	q.options["location"] = []float64{lon, lat}
	return q
}
1302057
func (c *Corpus) mergeEXIFGPSRow(k, v []byte) error {
	wholeRef, ok := blob.ParseBytes(k[len("exifgps|"):])
	pipe := bytes.IndexByte(v, '|')
	if pipe < 0 || !ok {
		return fmt.Errorf("bogus row %q = %q", k, v)
	}
	lat, err := strconv.ParseFloat(string(v[:pipe]), 64)
	long, err1 := strconv.ParseFloat(string(v[pipe+1:]), 64)
	if err != nil || err1 != nil {
		if err != nil {
			log.Printf("index: bogus latitude in value of row %q = %q", k, v)
		} else {
			log.Printf("index: bogus longitude in value of row %q = %q", k, v)
		}
		return nil
	}
	c.gps[wholeRef] = latLong{lat, long}
	return nil
}
174993
func (p Point) Locator(precision int) (string, error) {
	return locator(p, precision)
}
943292
func (a *SetGeolocationOverrideArgs) SetLatitude(latitude float64) *SetGeolocationOverrideArgs {
	a.Latitude = &latitude
	return a
}
1347888
func PolylineFromLatLngs(points []LatLng) *Polyline {
	p := make(Polyline, len(points))
	for k, v := range points {
		p[k] = PointFromLatLng(v)
	}
	return &p
}
1291471
func (r Rect) Size() LatLng {
	return LatLng{s1.Angle(r.Lat.Length()) * s1.Radian, s1.Angle(r.Lng.Length()) * s1.Radian}
}