election

package
v0.0.0-...-eebe41d Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DataFolder = "dist/national_elb"

DataFolder is the name of the folder we expect to find the shapefiles under zoomlevel bucket subfolders.

View Source
const EarthRadius = 6378.137

EarthRadius is a rough estimate of earth's radius in km at latitude 0 if earth was a perfect sphere.

View Source
const EarthRadiusSq = EarthRadius * EarthRadius

EarthRadiusSq is a rough estimate of earth's radius, squared.

View Source
const (
	// DO NOT SUBMIT - replace with dummy key / empty key.
	MAPS_API_KEY string = "INSERT_API_KEY"
)
View Source
const MaxZoomForAllElectorates = 8

MaxZoomForAllElectorates is an arbitrary zoom level after which the 'all electorates' dataset becomes too large to send in one response.

View Source
const MaxZoomLevelToIgnorePollingPlaces = 8
View Source
const MinNumOfElectoratesToReturnAll = 100
View Source
const MinZoomLevelToShowUngroupedPollingPlaces = 14
View Source
const PolygonAreaToViewportThresholdRatio = 32
View Source
const TypeElectorateIds = "electorate_ids"
View Source
const TypeElectorateLabel = "electorate_label"
View Source
const TypePollingPlace = "polling_place"
View Source
const TypePollingPlaceGroup = "polling_place_group"

Variables

This section is empty.

Functions

func BboxToRect

func BboxToRect(bbox *shp.Box) (*rtree.Rect, error)

func CommonHeadersMiddleware

func CommonHeadersMiddleware(h http.Handler) http.Handler

CommonHeadersMiddleware adds common headers to the response and delegates to h for further processing of the request.

func Index

func Index(w http.ResponseWriter, r *http.Request)

Index is the http.HandlerFunc that serve the index.html page of our application. It's exported because it is handled differently to the other API handlers.

func NewAPIHandler

func NewAPIHandler() http.Handler

NewAPIHandler creates a single http.Handler for the election library HTTP API. Note that index is a separate http.HandlerFunc, as it requires a different set of headers.

func NewViewportResponse

func NewViewportResponse(rect *rtree.Rect, zoom ZoomLevel, originalZoom int) *viewportResponse

func ParseBboxToRect

func ParseBboxToRect(s string) (*rtree.Rect, error)

func ShpPolygonToGeojsonFeature

func ShpPolygonToGeojsonFeature(eps []*ElectoratePolygon) *geojson.Feature

Types

type Electorate

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

Electorate is a derivative from the Australian Election Committee definition of an electorate, including its polygons as defined in the shapefile, an ID and a few other attributes.

func (*Electorate) AssignToFeature

func (e *Electorate) AssignToFeature(feature *geojson.Feature)

func (Electorate) Bounds

func (e Electorate) Bounds() *rtree.Rect

Bounds returns the bounding box of an electorate multi polygon.

type ElectorateID

type ElectorateID string

ElectorateID is a unique identifier for an electorate in the system.

type ElectoratePolygon

type ElectoratePolygon struct {
	*shp.Polygon
	// contains filtered or unexported fields
}

ElectoratePolygon contains a single polygon (out of possibly many) for an electorate, as well as GIS details such as centroid and GIS ID.

type EncodedGeometry

type EncodedGeometry struct {
	Type        string     `json:"type"`
	Coordinates [][]string `json:"coordinates"`
}

EncodedGeometry correlates to a GeoJSON linear ring geometry, replacing coordinates with the encoded representation.

type EncodedPolylineFeature

type EncodedPolylineFeature struct {
	ID          string    `json:"id,omitempty"`
	Type        string    `json:"type"`
	BoundingBox []float64 `json:"bbox,omitempty"`
	// Geometry overrides the Feature's Geometry, allowing us to use the
	// encoded polyline algorithm.
	Geometry   *EncodedGeometry       `json:"geometry"`
	Properties map[string]interface{} `json:"properties"`
}

EncodedPolylineFeature correlates to a GeoJSON feature, allowing EncodedGeometry to replace Geometry.

func (*EncodedPolylineFeature) MarshalJSON

func (epf *EncodedPolylineFeature) MarshalJSON() ([]byte, error)

MarshalJSON returns JSON in a byte slice from a given encoded polyline feature.

type EncodedPolylineFeatureCollection

type EncodedPolylineFeatureCollection struct {
	Type        string        `json:"type"`
	BoundingBox []float64     `json:"bbox,omitempty"`
	Features    []MarshalJSON `json:"features"`
}

EncodedPolylineFeatureCollection correlates to a GeoJSON feature collection, but allows flexibility in the features it contains.

func (*EncodedPolylineFeatureCollection) MarshalJSON

func (epfc *EncodedPolylineFeatureCollection) MarshalJSON() ([]byte, error)

MarshalJSON returns JSON in a byte slice from a given encoded polyline feature collection.

type MarshalJSON

type MarshalJSON interface {
	MarshalJSON() ([]byte, error)
}

MarshalJSON provides a common interface between geojson.Feature, geojson.FeatureCollection and our encoded polyline implementation.

type PollingPlace

type PollingPlace struct {
	StateCode                        int
	StateAbbreviation                string
	DivisionName                     string
	DivisionId                       int
	DivisionCode                     int
	PrettyPrintName                  string
	PollingPlaceId                   int
	Status                           string
	PremisesName                     string
	Address1                         string
	Address2                         string
	Address3                         string
	AddressSuburb                    string
	AddressStateAbbreviation         string
	Postcode                         int
	AdvPremisesName                  string
	AdvAddress                       string
	AdvLocality                      string
	AdviceBoothLocation              string
	AdviceGateAccess                 string
	EntrancesDescription             string
	Lat                              float64
	Lng                              float64
	CensusCollectionDistrict         int
	WheelchairAccess                 string
	OrdinaryVoteEstimate             int
	DeclarationVoteEstimate          int
	NumberOrdinaryIssuingOfficers    int
	NumberDeclarationIssuingOfficers int
}

type ZoomLevel

type ZoomLevel int

ZoomLevel means one of a set of consumer viewport's zoom level when viewing maps. It is used in this context to choose a level of detail for electorate's polygons. Higher zoom means a greater level detail.

const NoZoomLevel ZoomLevel = ZoomLevel(0)

NoZoomLevel is the devault zoom level.

Jump to

Keyboard shortcuts

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