
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
**UTKDB** provides methods to initialize an in-browser database, load spatial data (from OpenStreetMap, CSV files or GeoJson's), extract layers, run custom SQL queries, and export data in GeoJSON format. The documentation below details each method along w
UTKDB provides methods to initialize an in-browser database, load spatial data (from OpenStreetMap, CSV files or GeoJson's), extract layers, run custom SQL queries, and export data in GeoJSON format. The documentation below details each method along with enhanced descriptions of their configuration interfaces, presented in table format for clarity.
Installation instructions can be added here.
Method | Purpose |
---|---|
init | Initializes the in-browser database and required packages. |
loadOsm | Loads OpenStreetMap (OSM) data from a PBF file URL into a table. It can extracts and loads specifics layers from the PBF too. |
loadCsv | Loads a CSV file into a table. |
loadLayer | Extracts and loads a specific layer from an OSM table. |
loadQuery | Executes a SQL query (with joins, filters, etc.) and creates a new table from the result. |
getLayer | Exports a layer (of type layer) as a GeoJSON FeatureCollection . |
createQuery | Returns a new QueryOperation object to construct a SQL query incrementally. |
applyQuery | Executes a given QueryOperation , runs the generated SQL, and logs the SQL to the console. |
init(): Promise<void>
Purpose:
Usage Example:
const spatialDb = new SpatialDb();
await spatialDb.init();
loadOsm(params: Params): Promise<OsmTable>
Purpose:
Params
(Method Parameters)
pbfFileUrl
(string, required) – The URL of the PBF file containing OpenStreetMap data.outputTableName
(string, required) – The name of the table where the extracted OSM data will be stored.boundingBox
(optional) – A geographic filter to limit data to a specific area:
minLat
/ maxLat
– Minimum and maximum latitude values.minLon
/ maxLon
– Minimum and maximum longitude values.autoLoadLayers
(optional) – Configuration for automatically extracting and load specific layers:
coordinateFormat
(string) – Defines the format in which coordinates should be stored.layers
(array) – A list of layers to be extracted and stored in separate tables ('surface' | 'coastline' | 'water' | 'parks' | 'roads' | 'buildings').OsmTable
(Return Type)
name
(string) – The name of the table.columns
(array) – A list of columns describing the structure of the table.type
(string, fixed to 'osm'
) – Specifies that this is an OSM table.Usage Example:
// Just loading pbf
await spatialDb.loadOsm({
pbfFileUrl: 'https://example.com/osm.pbf',
outputTableName: 'my_pbf_table',
});
// Loading pbf and layers
await spatialDb.loadOsm({
pbfFileUrl: 'https://example.com/osm.pbf',
outputTableName: 'my_pbf_table',
autoLoadLayers: {
coordinateFormat: this.projection,
layers: ['surface' | 'coastline' | 'parks' | 'water' | 'roads' | 'buildings'],
},
});
// [TODO] Add bouding box example when check if its working
loadCsv(params: Params): Promise<CsvTable>
Purpose:
Params
(Method Parameters)
csvFileUrl
(string, required) – The URL of the CSV file.outputTableName
(string, required) – The name of the table where the extracted CSV data will be stored.delimiter
(string, optional) – The Delimiter of the CSV file. By default, it will use ,
geometryColumns
(optional) – Specific geometric attributes to understand it as a geometric point (important to make spatial joins after, for example):
latColumnName
(string, required) – Latitude column name of point.longColumnName
(string, required) – Longitude column name of point.coordinateFormat
(string, optional) – Coordinate type (it will use EPSG:4326
by default).CsvTable
(Return Type)
name
(string) – The name of the table.columns
(array) – A list of columns describing the structure of the table.type
(string, fixed to 'csv'
) – Specifies that this is an CSV table.Usage Example:
// Load csv
await spatialDb.loadCsv({
csvFileUrl: 'https://example.com/data.csv',
outputTableName: 'csv_table',
});
// Load csv, specifying different delimiter and geometric columns
await spatialDb.loadCsv({
csvFileUrl: 'https://example.com/data.csv',
outputTableName: 'csv_table',
delimiter: ';',
geometryColumns: {
latColumnName: 'latitude',
longColumnName: 'longitude',
coordinateFormat: 'WGS84',
},
});
loadLayer(params: Params): Promise<LayerTable>
Purpose:
Params
(Method Parameters)
osmInputTableName
(string, required) – Table name of an OSM Table.outputTableName
(string, required) – The name of the table where the extracted layer data will be stored.layer
(string, required) – Which layer do you want to load (surface' | 'coastline' | 'parks' | 'water' | 'roads' | 'buildings)coordinateFormat
(string, optional) – Coordinate type (it will use EPSG:4326
by default).LayerTable
(Return Type)
name
(string) – The name of the table.columns
(array) – A list of columns describing the structure of the table.type
(string, fixed to 'layer'
) – Specifies that this is a Layer table.Usage Example:
await spatialDb.loadLayer({
osmInputTableName: 'osm_table',
outputTableName: 'layer_table',
layer: 'roads',
coordinateFormat: 'WGS84',
});
loadQuery(query: QueryOperation, outputTableName: string): Promise<Table>
Purpose:
QueryOperation
(What is it?)
spatialDb.createQuery...
(better explained in this class method description [TODO] add a link for it). It contains all information of query you want to load.LayerTable
(Return Type)
name
(string) – The name of the table.columns
(array) – A list of columns describing the structure of the table.type
(string, depends on root table) – Specifies which table you have in response. If your query is in a LayerTable, for example, the type here will be a Layer. Same occurs if its a csv, or any other.Usage Example:
const query = spatialDb.createQuery('layer_table').spatialJoin({
tableRootName: 'layer_table', // if its a layer, loadQuery will create this new table as a Layer too
tableJoinName: 'other_data_table',
spatialPredicate: 'NEAR',
nearDistance: 0.01,
joinType: 'LEFT',
});
await spatialDb.loadQuery(query, 'output_table');
getLayer(layerTableName: string): Promise<FeatureCollection>
Purpose:
loadLayer
method.FeatureCollection
(Return Type)
Usage Example:
const geojson = await spatialDb.getLayer('my_layer_table');
createQuery(tableName: string): QueryOperation
Purpose:
Which operations do you have?
filter: will add where
in query to filter data based in a logic. Params:
tableName
(string, optional) – The name of the table you want to filter. By default, will consider createQuery table name (main table of query). But if you want to filter based on a join, for example, you can pass a different tableName.column
(string) – Column of table you want to filter.value
(string) – Column of table you want to filter.select: will add custom select
, to select just specific attributes in your query
tableName
(string, optional) – The name of the table you want to select attributes. By default, will consider createQuery table name (main table of query). But if you want to select based on a join, for example, you can pass a different tableName.columns
(string[]) – Array of column names you want to filter.join: allows joining another table into your query.
'INNER'
, 'LEFT'
, 'RIGHT'
, 'FULL'
.spatialJoin: performs a spatial join between two tables based on spatial relationships.
INTERSECT
). Options:
'INTERSECT'
: Includes records where geometries from both tables intersect.'NEAR'
: Includes records where geometries are within a certain distance.'INNER'
, 'LEFT'
, 'RIGHT'
, 'FULL'
.'NEAR'
. Specifies the maximum distance between geometries to be considered a match.getSql: will return raw sql string of operation you create.
getMainTable: will return main table name of your query (table name you passed on createQuery
).
Usage Example:
/*
Example 01:
- Join user table with other user data table.
- Filter just user with one specific email (will create a where for it)
- Select just attributes you want too (from user table and other user data table)
*/
const query = spatialDb
.createQuery('user_csv_table')
.join({
tableRootName: 'user_csv_table',
tableJoinName: 'other_user_data_table',
})
.filter({ tableName: 'user_csv_table', column: 'email', value: 'lucasalexandre@id.uff.br' })
.select({ tableName: 'user_csv_table', columns: ['id', 'email'] })
.select({ tableName: 'other_user_data_table', columns: ['other_data'] });
console.log(query.getSql());
/*
Example 02:
- Spatial join of a layer with a csv, using NEAR operation with distance of 0.01
*/
const query = spatialDb.createQuery('my_layer').spatialJoin({
tableRootName: 'my_layer',
tableJoinName: 'csv_table',
spatialPredicate: 'NEAR',
nearDistance: 0.01,
});
console.log(query.getSql());
applyQuery(query: QueryOperation): Promise<any> [TODO] type this response if possible
Purpose:
Here are some planned improvements and features to be implemented in the future:
pode ser problema de estar invertido o lat/long?
onde fica a geometria? e as propriedades? tentar dar uma unificada nesses formatos, tanto no normal quanto no custom
ser fácil de selecionar só os atributos importantes (até se estiverem dentro de um "map")
inputs
quanto nos outputs
.FAQs
**UTKDB** provides methods to initialize an in-browser database, load spatial data (from OpenStreetMap, CSV files or GeoJson's), extract layers, run custom SQL queries, and export data in GeoJSON format. The documentation below details each method along w
We found that autk-db demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.