geodata

package
v0.0.0-...-2c14cb9 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CensusQuerySQL

func CensusQuerySQL(ctx context.Context, args CensusQuerySQLArgs) (sql string, include []string, err error)

func CheckOverlapsUK

func CheckOverlapsUK(coords []float64) error

CheckOverlapsUK validates each point in the flat coordinate list. Each point must be a valid lon/lat and the bounding box of all coordinates in the list must overlap the UK bounding box.

func ExtractSpecialCols

func ExtractSpecialCols(set *where.ValueSet) ([]string, *where.ValueSet, error)

ExtractSpecialCols removes special column names like "geography_code" from the ValueSet, returning a reduced ValueSet, and the list of special columns found.

func FixGeotype

func FixGeotype(token string) (string, error)

func MapGeotypes

func MapGeotypes(set *where.ValueSet) (*where.ValueSet, error)

MapGeotypes changes case-insensitive geotypes given in query strings to the specific case-sensitive geotypes used in the db. For example, "lsoa" will be changed to "LSOA". Returns error if a geotype doesn't match at all.

func ValidateAllToken

func ValidateAllToken(set *where.ValueSet) error

ValidateAllToken verifies that if there is an "ALL" specified, it is the only token.

Types

type CensusQuerySQLArgs

type CensusQuerySQLArgs struct {
	Year        int
	Geos        []string
	BBox        string
	Location    string
	Radius      int
	Polygon     string
	Geotypes    []string
	Cols        []string
	Censustable string
}

type Chunk

type Chunk struct {
	// contains filtered or unexported fields
}

Chunk holds multiple catgeory data for a single geocode

type CkmeansParser

type CkmeansParser struct {
	// contains filtered or unexported fields
}

CkmeansParser holds data and methods neccessary to parse and process data for ckmeans queries

func NewCkmeansParser

func NewCkmeansParser(divideBy string, k int) *CkmeansParser

New creates a new CkmeansParser.

type Geodata

type Geodata struct {
	// contains filtered or unexported fields
}

func New

func New(db *database.Database, cant *cantabular.Client, maxMetrics int) (*Geodata, error)

func (*Geodata) CKmeans

func (app *Geodata) CKmeans(ctx context.Context, year int, cat []string, geotype []string, k int, divideBy string) (map[string]map[string][]float64, error)

CKmeans does an 'all rows' query for census data using sql generator from geodata pkg, parses the results by category and then by geotype, and gets ckmeans breaks for each geotype in each category. Optionally, if divideBy is not blank, will divide all categories by the cateogry indicated by the divideBy value, prior to getting ckmeans breaks.

func (*Geodata) CKmeansRatio

func (app *Geodata) CKmeansRatio(ctx context.Context, year int, cat1 string, cat2 string, geotype string, k int) ([]float64, error)

!!!! DEPRECATED CKMEANSRATIO TO BE REMOVED WHEN FRONT END REMOVES DEPENDENCY ON IT !!!!

func (*Geodata) CantabularMetrics

func (app *Geodata) CantabularMetrics(ctx context.Context, geocodes []string, catset *where.ValueSet, geotype string) ([]byte, error)

Retrieve metrics from Cantabular.

func (*Geodata) Geo

func (app *Geodata) Geo(ctx context.Context, year int, geocode string, geoname string) (*Resp, error)

func (*Geodata) PGMetrics

func (app *Geodata) PGMetrics(ctx context.Context, year int, geocodes []string, catset *where.ValueSet, include []string, censustable string) ([]byte, error)

Retrieve metrics from postgres.

func (*Geodata) Query

func (app *Geodata) Query(ctx context.Context, year int, bbox, location string, radius int, polygon string, geotypes, rows, cols []string, censustable string) (string, error)

func (*Geodata) Query2

func (app *Geodata) Query2(ctx context.Context, year int, bbox, location string, radius int, polygon string, geotypes, geos []string) ([]string, error)

Proposed replacement for Query. This version separates selecting geocodes from selecting metrics.

type Resp

type Resp struct {
	Meta struct {
		Name    string `json:"name"`
		Code    string `json:"code"`
		Geotype string `json:"geotype"`
	} `json:"meta"`
	GeoJSON *geojson.FeatureCollection `json:"geo_json"`
}

Jump to

Keyboard shortcuts

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