Home Reference Source Test
public class | source

Choropleth

Extends:

Map → Choropleth

Choropleth implementation.

Constructor Summary

Public Constructor
public

constructor(bgmap: BGMapWrapper, geometry: JSON, userOptions: Object)

Creates an instance of Choropleth.

Member Summary

Public Members
public

The Legend to be used through the life of the map.

Method Summary

Public Methods
public

Method called to build the Map Legend.

public

defaults(): {colorScheme: string[], numberOfClasses: number}

Returns the color scheme and number of classes associated with the id given.

public

draw()

Draw Choropleth map, at the beginning and when the map is moved.

public

getDefaultColors(numClasses: number, dataNature: string): Array<Array<RGB>>

Returns the colors for this map given the number of classes and the nature of the data (sequential, diverging or qualitative).

Inherited Summary

From class Map
public

Aesthetic objects that were saved.

public

This is the Gisplay API Background map wrapper.

public

JSON object with the geometry that was read from the file.

public

All the options available in the Gisplay API.

public

Polygons do/do not exist.

public

This map unique identifier.

public

kdtree: kdTree

KdTree object to hold that will be used to calculate the closest point to the coordinates where the user made a click.

public

This is the maixmum value found on the dataset.

public

This is the minimum value found on the dataset.

public

rtree: PolygonLookup

RBush(Rtree implementation) that is used to calculate the polygon closest to the coordinates where the user made a click.

public

Holds the points for each Aesthethic object.

public

treepoints: Array<{lon: number, lat: number, properties: JSON}>

This object holds for each point it's long, lat and associated properties. This points will be used by k-d Tree. And k-d Tree is used to find the closest point to where the user clicked.

private
public abstract

buildLegend(): void

M17) Creates a Legend element suitable for polygons based on the Aesthethic objects.

public

buildTrees(geojson: JSON): void

M19) Receives the dataset as parameter.

public

calcClassBreaks(numberValues: number[], classBreakMethod: string, numberOfClasses: number): number[]

M12) Calculates the class breaks using the algorithm given(k-means, quantile or equidistant).

public

clear()

M22) Clear current buffers to preset values.

public

clickEvent(lng: number, lat: number)

To be called when the user clicks on the map.

public

createAndInsertFeature(featureId: number, geometry: JSON, properties: JSON)

M14) Creates a Feature and then calls a method to insert said Feature in one or more Aesthetic objects.

public

M4) Creates a canvas element and WebGL associated information.

public abstract

M10) Defaults for each map.

public abstract

draw()

M21) Draw map function.

public

drawBorders(aes: Aesthetic): void

M24) Receiving an Aesthetics object, draws the borders contained in it's Features, aplying the color specified in the Aeshteic object for the line color(Aeshteic.strokeColor).

public

drawPoints(aes: Aesthetic): void

M26) Receiving an Aesthetics object, draws the points contained in it's Features, aplying the values specified in that Aesthetic object visual variables (color and size).

public

M27) Receiving an Aesthetics object, draws the points contained in it's Features, aplying the color specified in the Aeshteic object for the line color(Aeshteic.strokeColor) and the size of the point is based on the attribute value and the specified limits.

public

drawTriangles(aes: Aesthetic): void

M23) Receiving an Aesthetics object, draws the triangles contained in it's Features, using the color that the Aesthethics object has.

public

fitFeature(properties: JSON): Array<number>

M18) Returns an array of Aesthetic ids that tells us the objects where the Feature belongs.

public abstract

getDefaultColors(numClasses: number, dataNature: string): Array<Array<RGB>>

Returns the colors for this map given the number of classes and the nature of the data (sequential, diverging or qualitative).

public

M3) Initializes the API by: creating canvas, the WebGL program and setting up all needed events.

public

insertFeature(id: number, properties: JSON, triangles: {itemSize: number, numItems: number}, borders: {itemSize: number, numItems: number}, points: {itemSize: number, numItems: number}): void

M17) Inserts the Feature into one or more Aesthetic objects.

public

insertGroupedFeature(id: number, triangles: {itemSize: number, numItems: number}, borders: {itemSize: number, numItems: number}, points: {itemSize: number, numItems: number})

M20) Similar to insertFeature, in this case inserts a group of Features like it was only one.

public

loadGeoJSON(geojson: JSON)

M13) Loads GeoJSON object that came from the file uploaded by the user.

public

loadOptions(userOptions: Object, bgmap: Object)

M1) Loads user and default options.

public

M9) Method that executes all the process associated with the creation of the thematic map.

public

preProcessData(geojson: JSON, numberOfClasses: number, classBreaksMethod: string, colorScheme: string[])

M11) Creates Aesthetic objects.

public abstract

This function should be implemented by any subclass that wants to use another way of processing data.

public

processPolygon(polygon: {geometry: JSON, properties: JSON}): {triangles: Array<number>, vertices: Array<number>}

M15) Deals with polygon triangulation.

public

searchKdTree(lon: number, lat: number): void

Search the rtree for the closest point from the lng, lat that was clicked.

public

searchRTree(lng: number, lat: number): void

Search the rtree for the closest polygon from the lng, lat that was clicked.

public

setMatrices(gl: *)

This method will set all matrices needed to compute each point/vertex position.

public

setupEvents(mappos: number): void

M8) Setup all events used by the API.

public

M2) Calls the Background Map Wrapper to create the loader to be used later when the user feeds data to the API.

Public Constructors

public constructor(bgmap: BGMapWrapper, geometry: JSON, userOptions: Object) source

Creates an instance of Choropleth.

Override:

Map#constructor

Params:

NameTypeAttributeDescription
bgmap BGMapWrapper

Background map object.

geometry JSON

JSON object with the geometry that was read from the file.

userOptions Object

User options to be used.

Public Members

public legend: Legend source

The Legend to be used through the life of the map.

Public Methods

public buildLegend() source

Method called to build the Map Legend. For all Aesthethics that exist crate one polygon row and then insert the Legend to the map.

Override:

Map#buildLegend

public defaults(): {colorScheme: string[], numberOfClasses: number} source

Returns the color scheme and number of classes associated with the id given.

Override:

Map#defaults

Return:

{colorScheme: string[], numberOfClasses: number}

Color scheme and number of classes associated with the id given, empty object otherwise.

public draw() source

Draw Choropleth map, at the beginning and when the map is moved.

Override:

Map#draw

See:

public getDefaultColors(numClasses: number, dataNature: string): Array<Array<RGB>> source

Returns the colors for this map given the number of classes and the nature of the data (sequential, diverging or qualitative).

Override:

Map#getDefaultColors

Params:

NameTypeAttributeDescription
numClasses number

Number of classes.

dataNature string

Nature of the data.

Return:

Array<Array<RGB>>

Default colors for the map given the number of classes and nature of data.