_buildSchemaFromFeature(feature)

Builds a table schema from a geojson feature each schema in the db is essentially the same except for geometry type * which is based off the geometry of the feature passed in here

parameter type description
feature Object

a geojson feature * @returns {string} schema

_createIndex(table, name, callback)

Creates an index on a given table *

parameter type description
table string

the table to index

name string

the name of the index * @param {string} using - the actual field and type of the index

callback function

the callback when the query returns

_createTable(name, callback)

Creates a new table checks to see if the table exists, create it if not

parameter type description
name string

the name of the index * @param {string} schema - the schema to use for the table * @param {Array} indexes - an array of indexes to place on the table

callback function

the callback when the query returns

_insertFeature(table, feature, i)

Creates the sql needed to insert the feature

parameter type description
table string

the table to insert into

feature Object

a geojson feature

i string

index value to use an id

_query(sql, callback)

Executes SQL again the DB uses connection pooling to connect and query

parameter type description
sql string

the sql to run

callback function

the callback when db returns

applyCodedDomains(fieldName, value, fields)

Check for any coded values in the fields if we find a match, replace value with the coded val

parameter type description
fieldName string

the name of field to look for

value number

the coded value

fields Array

a list of fields to use for coded value replacements

connect(conn, koop, optional)

Connect to the db with a connection string

parameter type description
conn string

the connection string to the db with user/pass/host/dbname

koop Object

an instance of koop, mainlt for central/shared logging

optional function

callback for when the db is ready

countDistinctGeoHash(table, precision, callback)

Get the count of distinct geohashes for a query

parameter type description
table string

the table to query

precision string

the precision at which to extract the distinct geohash counts * @param {Object} options - optional params like where and geometry

callback function

the callback when the query returns

createFilterFromSql(sql, fields)

Determines if a range or like filter is needed * appends directly to the sql passed in

parameter type description
sql string

a sql where clause

fields Array

a list of fields in to support coded value domains

createGeohash(feature, precision)

Creates a geohash from a features computes the centroid of lines and polygons

parameter type description
feature Object

a geojson feature

precision number

the precision at which the geohash will be created

Returns

string :

geohash

createLikeFilterFromSql(sql, fields)

Create a "like" filter for query string values

parameter type description
sql string

a sql where clause

fields Array

a list of fields in to support coded value domains

createRangeFilterFromSql(sql, fields)

Creates a "range" filter for querying numeric values

parameter type description
sql string

a sql where clause

fields Array

a list of fields in to support coded value domains

createWhereFromSql(where, fields)

Creates a viable SQL where clause from a passed in SQL (from a url "where" param)

parameter type description
where string

a sql where clause

fields Array

a list of fields in to support coded value domains

Returns

string :

sql

dropTable(table, callback)

Drops a table from the DB

parameter type description
table string

the table to drop

callback function

the callback when the query returns

geoHashAgg(table, limit, precision, options, callback)

Get a geohash aggregation for a set of features in the db this will auto-reduce the precision of the geohashes if the given * precision exceeds the given limit.

parameter type description
table string

the table to query

limit number

the max number of geohash to send back

precision string

the precision at which to extract geohashes

options Object

optional params like where and geometry

callback function

the callback when the query returns

getCount(table, options, callback)

Gets the count of all features in a table

parameter type description
table string

the table name

options Object

optional params from the querystring like where and geometry

callback function

returns the count

getInfo(table, callback)

Gets the info/metadata from the koopinfo table in the db

parameter type description
table string

the table name

callback function

returns the info Object

getStat(table, field, outName, type, options, callback)

Gets a statistic on one field at a time Supports where and geometry filters and group by

parameter type description
table string

to get data from

field string

to generate stats from

outName string

the name of the stat field

type string

the stat type: min, max, avg, count, var, stddev

options Object

optional params for the query: where, geometry, groupBy

callback function

when the query is done

insert(id, geojson, layerId, callback)

Creates a table and inserts features and metadat creates indexes for each property in the features and substring indexes on geohashes

parameter type description
id string

the dataset id to insert into

geojson Object

geojson features

layerId number

the layer id for this dataset

callback function

the callback when the query returns

insertPartial(id, geojson, layerId, callback)

Inserts an array of features used as a way to insert pages of features, and only features, not metadata

parameter type description
id string

the dataset id to insert into

geojson Object

geojson features

layerId number

the layer id for this dataset

callback function

the callback when the query returns

parseGeometry(geometry)

Parses a geometry Object

parameter type description
geometry string

a geometry used for filtering data spatially

remove(id, callback)

Removes everything in the DB for a given idea will delete all metadata, timers, and features *

parameter type description
id string

the dataset id to remove

callback function

the callback when the query returns

select(id, options, callback)

Get features out of the db

parameter type description
id string

the dataset id to insert into

options Object

optional params used for filtering features (where, geometry, etc)

callback function

the callback when the query returns

serviceCount(type, callback)

Gets the count of the number of services registered for a given type

parameter type description
type string

the type of service: agol, socrata, ckan, etc.

callback function

the callback when the query returns

serviceGet(type, id, callback)

Gets a service for a given type and id if no id is sent it returns an array of every service for that type

parameter type description
type string

the type of service: agol, socrata, ckan, etc.

id string

the id to use for the service

callback function

the callback when the query returns

serviceRegister(type, info, callback)

Register a new service in the DB with the given type and info

parameter type description
type string

the type of service: agol, socrata, ckan, etc.

info Object

Object containing a host and id for this service

callback function

the callback when the query returns

serviceRemove(type, id, callback)

Removes a service for a given type and id from the DB

parameter type description
type string

the type of service: agol, socrata, ckan, etc.

id string

the id to use for the service

callback function

the callback when the query returns

timerGet(table, callback)

Gets the current timer for a given table timers are used throttle API calls by preventing providers from * over-calling an API.

parameter type description
table string

the table to query

callback function

the callback when the query returns

timerSet(table, callback)

Sets new timer for a given table

parameter type description
table string

the table to query

callback function

the callback when the query returns

updateInfo(table, info, callback)

Updates/overwrites the info/metadata for dataset in the db

parameter type description
table string

the table name

info Object

the metadata Object to insert into the koopinfo table

callback function

returns the info Object