places

package
v0.0.0-...-c8acfb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package places provides global location information to enrich metadata with location details.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const ApiName = "places"

ApiName is the backend API name.

Variables

View Source
var Key = "f60f5b25d59c397989e3cd374f81cdd7710a4fca"
View Source
var Retries = 2

Retries specifies the number of attempts to retry the service request.

View Source
var RetryDelay = 100 * time.Millisecond

RetryDelay specifies the waiting time between retries.

View Source
var Secret = "photoprism"
View Source
var ServiceUrls = []string{
	"https://places.photoprism.app/v1/location/%s",
}

ServiceUrls specifies the reverse geocoding service URLs.

View Source
var UserAgent = ""

Functions

func PerformRequest

func PerformRequest(serviceUrl, id string) (r *http.Response, err error)

PerformRequest fetches the cell ID data from the service URL.

Types

type Location

type Location struct {
	ID          string  `json:"id"`
	LocLat      float64 `json:"lat"`
	LocLng      float64 `json:"lng"`
	LocName     string  `json:"name"`
	LocStreet   string  `json:"street"`
	LocPostcode string  `json:"postcode"`
	LocCategory string  `json:"category"`
	Place       Place   `json:"place"`
	Cached      bool    `json:"-"`
}

Location represents a specific geolocation identified by its S2 ID.

func FindLocation

func FindLocation(id string) (result Location, err error)

FindLocation retrieves location details from the backend API.

func (Location) Category

func (l Location) Category() (result string)

Category returns the location category if any.

func (Location) CellID

func (l Location) CellID() string

CellID returns the S2 cell identifier string.

func (Location) City

func (l Location) City() (result string)

City returns the location address city name.

func (Location) CountryCode

func (l Location) CountryCode() (result string)

CountryCode returns the location address country code.

func (Location) District

func (l Location) District() (result string)

District returns the location address district name.

func (Location) Keywords

func (l Location) Keywords() (result []string)

Keywords returns location keywords if any.

func (Location) Label

func (l Location) Label() (result string)

Label returns the location label.

func (Location) Latitude

func (l Location) Latitude() (result float64)

Latitude returns the location position latitude.

func (Location) Longitude

func (l Location) Longitude() (result float64)

Longitude returns the location position longitude.

func (Location) Name

func (l Location) Name() (result string)

Name returns the location name if any.

func (Location) PlaceID

func (l Location) PlaceID() string

PlaceID returns the place identifier string.

func (Location) Postcode

func (l Location) Postcode() (result string)

Postcode returns the location postcode if any.

func (Location) Source

func (l Location) Source() string

Source returns the backend API name.

func (Location) State

func (l Location) State() (result string)

State returns the location address state name.

func (Location) Street

func (l Location) Street() (result string)

Street returns the location street if any.

type Place

type Place struct {
	PlaceID     string `json:"id"`
	LocLabel    string `json:"label"`
	LocDistrict string `json:"district"`
	LocCity     string `json:"city"`
	LocState    string `json:"state"`
	LocCountry  string `json:"country"`
	LocKeywords string `json:"keywords"`
}

Place represents a region identified by city, state, and country.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL