Skip to content

Add hex well known binary format support (.wkb) #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"onLanguage:kml",
"onLanguage:gml",
"onLanguage:shp",
"onLanguage:wkt"
"onLanguage:wkt",
"onLanguage:wkb"
],
"main": "./dist/extension.js",
"contributes": {
Expand Down Expand Up @@ -214,7 +215,7 @@
"explorer/context": [
{
"command": "map.view",
"when": "resourceFilename =~ /.*\\.(csv|fgb|igc|gml|gpx|json|geojson|kgl|kml|shp|topojson|wkt)/",
"when": "resourceFilename =~ /.*\\.(csv|fgb|igc|gml|gpx|json|geojson|kgl|kml|shp|topojson|wkt|wkb)/",
"group": "navigation"
}
],
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LogLevel } from "./logger";
// log level setting for prod. vs. dev run of this ext.
export const logLevel: LogLevel = LogLevel.Info; // change to .Debug for dev ...

export const supportedDataFiles: RegExp = /.*\.(csv|dbf|fgb|gpx|json|geojson|gml|kgl|kml|prj|shp|topojson|wkt)/;
export const supportedDataFiles: RegExp = /.*\.(csv|dbf|fgb|gpx|json|geojson|gml|kgl|kml|prj|shp|topojson|wkt|wkb)/;

export const mapboxToken: string = 'pk.eyJ1IjoiZGF0YXBpeHkiLCJhIjoiY2s1Mm10bHB1MThnbDNrdGVmemptd3J5eSJ9.xewq9dOWQLemerED1-qPXQ';

Expand All @@ -16,6 +16,7 @@ export const openFileFilters: any = {
'IGC': ['igc'],
'Shapefile': ['shp'],
'WKT': ['wkt'],
'WKB': ['wkb'],
'FlatGeobuf': ['fgb']
};

Expand Down
1 change: 1 addition & 0 deletions src/map.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export class MapView {
case '.igc':
case '.gml':
case '.wkt':
case '.wkb':
// just pass through raw string content
this._mapData = this._content;
this.refreshMapView();
Expand Down
9 changes: 9 additions & 0 deletions web/scripts/map.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ function initializeMap(keplerGl, store, config, data, dataType) {
data = KeplerGl.processGeojson(data);
tagData = true;
break;
case '.wkb':
// read WKB data
const wkbFormat = new ol.format.WKB();
const wkbFeatures = wkbFormat.readFeatures(data, {hex: true});
geoDataFeatures = geoJsonFormat.writeFeatures(wkbFeatures);
data = JSON.parse(geoDataFeatures);
data = KeplerGl.processGeojson(data);
tagData = true;
break;
case 'geo.json':
case '.geojson':
case '.gpx':
Expand Down