Documentation ¶
Index ¶
- Constants
- func AddRegion(db DatabaseInterface, lat float64, lng float64)
- func ContainsRegion(db DatabaseInterface, lat float64, lng float64) bool
- func ReportImage(db DatabaseInterface, id string, reason string, logger reporting.Logger)
- type BySum
- type DatabaseInterface
- type ImageData
- func GetImages(db DatabaseInterface, lat float64, lng float64) []ImageData
- func GetImagesWithEnd(db DatabaseInterface, lat float64, lng float64, end int) []ImageData
- func GetImagesWithRange(db DatabaseInterface, lat float64, lng float64, start int, end int) []ImageData
- func GetImagesWithStart(db DatabaseInterface, lat float64, lng float64, start int) []ImageData
- func NewImage(caption string, createdTime int64, imageURL string, thumbnailURL string, ...) *ImageData
- func NewImageWithDistance(caption string, createdTime int64, imageURL string, thumbnailURL string, ...) *ImageData
- type Location
- type MongoInterface
- func (c *MongoInterface) AddBulkImagesToRegion(images []ImageData, region *Location)
- func (c *MongoInterface) AddImage(image ImageData)
- func (c *MongoInterface) AddRegion(lat float64, lng float64)
- func (c *MongoInterface) Close()
- func (c *MongoInterface) Copy() DatabaseInterface
- func (c *MongoInterface) DeleteOldImages(amount int)
- func (c *MongoInterface) GetAllImages() []ImageData
- func (c *MongoInterface) GetImages(lat float64, lng float64, start int, end int) []ImageData
- func (c *MongoInterface) GetRegions() []Location
- func (c *MongoInterface) Size() int
- func (c *MongoInterface) SoftDelete(id string, reason string)
- type User
Constants ¶
const RecencyBias = 350
RecencyBias is a multiplier used to create a more equal weighting between recency and distance
const RegionSize = 5000
RegionSize is radius of a region in meters
Variables ¶
This section is empty.
Functions ¶
func AddRegion ¶
func AddRegion(db DatabaseInterface, lat float64, lng float64)
AddRegion - adds a new region for image population
func ContainsRegion ¶
func ContainsRegion(db DatabaseInterface, lat float64, lng float64) bool
ContainsRegion - determines whether a point is within a specific region
func ReportImage ¶
func ReportImage(db DatabaseInterface, id string, reason string, logger reporting.Logger)
ReportImage - report an image to be removed @param id - the image ID which should match one in ImageData @param reason - reason for reporting @param logger - optional logging functionality
Types ¶
type DatabaseInterface ¶
type DatabaseInterface interface { GetRegions() []Location AddRegion(lat float64, lng float64) AddImage(image ImageData) AddBulkImagesToRegion(images []ImageData, region *Location) GetImages(lat float64, lng float64, start int, end int) []ImageData GetAllImages() []ImageData SoftDelete(id string, reason string) DeleteOldImages(amount int) Size() int Copy() DatabaseInterface Close() }
DatabaseInterface - a generic interface for database queries
func NewMongoInterface ¶
func NewMongoInterface() DatabaseInterface
NewMongoInterface - use to create a new mongo connection
type ImageData ¶
type ImageData struct { Caption string `json:"caption" bson:"caption"` CreatedTime int64 `json:"createdTime" bson:"createdTime"` ImageURL string `json:"url" bson:"url"` Link string `json:"link" bson:"link"` User *User `json:"user" bson:"user"` ThumbnailURL string `json:"thumbnail_url" bson:"thumbnail_url"` ID string `json:"id" bson:"_id"` Location *Location `json:"location" bson:"location"` // regions are specified imageops.go Region *Location `json:"region" bson:"region"` // where the photo was taken Coordinates []float64 `json:"coordinates" bson:"coordinates"` // will be set when querying using DatabaseInterface Distance float64 `json:"distance" bson:"distance"` // the source of the image Source string `json:"source" bson:"source"` }
ImageData is data that is stored and returned from `hanapi`
func GetImages ¶
func GetImages(db DatabaseInterface, lat float64, lng float64) []ImageData
GetImages - get images near the location sorted by distance and recency
func GetImagesWithEnd ¶
func GetImagesWithEnd(db DatabaseInterface, lat float64, lng float64, end int) []ImageData
GetImagesWithEnd - get images from the beginning to the specified end
func GetImagesWithRange ¶
func GetImagesWithRange(db DatabaseInterface, lat float64, lng float64, start int, end int) []ImageData
GetImagesWithRange - Specify a range, so that you can query a portion of the image list @param start - start is optional, use -1 to signify no value, indexing starts at zero @param end - end is optional, use -1 to signify no value
func GetImagesWithStart ¶
func GetImagesWithStart(db DatabaseInterface, lat float64, lng float64, start int) []ImageData
GetImagesWithStart - get images starting at a certain point
func NewImage ¶
func NewImage(caption string, createdTime int64, imageURL string, thumbnailURL string, id string, lat float64, lng float64, link string, user string, profilePictureURL string, source string) *ImageData
NewImage returns a new image that's suitable for being added to the database. Note that region is not specified here, this is done before entry into the database. This is because the collectors have no real idea of which query belongs to which region
func NewImageWithDistance ¶
func NewImageWithDistance(caption string, createdTime int64, imageURL string, thumbnailURL string, id string, lat float64, lng float64, distance float64) *ImageData
NewImageWithDistance returns a new image with distance specified Created purely for testing purposes, so that the distance can be specified
type Location ¶
Location is a type which contains the lat and lng
func GetRegion ¶
func GetRegion(db DatabaseInterface, lat float64, lng float64) *Location
GetRegion - returns the region which the specified lat, lng lies in
func GetRegions ¶
func GetRegions(db DatabaseInterface) []Location
GetRegions - returns the currently used regions
func NewLocation ¶
NewLocation returns a new location
type MongoInterface ¶
type MongoInterface struct { DatabaseInterface // contains filtered or unexported fields }
MongoInterface - a mongodb implementation of `DatabaseInterface`
func (*MongoInterface) AddBulkImagesToRegion ¶
func (c *MongoInterface) AddBulkImagesToRegion(images []ImageData, region *Location)
AddBulkImagesToRegion adds new images in bulk, also setting the region
func (*MongoInterface) AddImage ¶
func (c *MongoInterface) AddImage(image ImageData)
AddImage adds new image data for the feed
func (*MongoInterface) AddRegion ¶
func (c *MongoInterface) AddRegion(lat float64, lng float64)
AddRegion adds this new location as a place to query images on
func (*MongoInterface) Close ¶
func (c *MongoInterface) Close()
Close will close the current mongo connection
func (*MongoInterface) Copy ¶
func (c *MongoInterface) Copy() DatabaseInterface
Copy the interface for added concurrency
func (*MongoInterface) DeleteOldImages ¶
func (c *MongoInterface) DeleteOldImages(amount int)
DeleteOldImages will clear `amount` worth of images starting at the oldest
func (*MongoInterface) GetAllImages ¶
func (c *MongoInterface) GetAllImages() []ImageData
GetAllImages returns all images stored
func (*MongoInterface) GetRegions ¶
func (c *MongoInterface) GetRegions() []Location
GetRegions returns the watched locations that are stored in the database These locations are queried to populate the database with images
func (*MongoInterface) Size ¶
func (c *MongoInterface) Size() int
Size will return the amount of images in the database
func (*MongoInterface) SoftDelete ¶
func (c *MongoInterface) SoftDelete(id string, reason string)
SoftDelete will add a delete field to image so it's no longer visible in feed