Class: Shapefile

Shapefile

A class reading local shp files. This class only supports reading of the shp files. For support reading all the files of a shapefile (shp, dbf, prj), check bu.format.local.ZIP.


new Shapefile()

Source:
bu/format/shapefile.js

Extends

Methods


createGeoJSON(buffer)

Returns a Promise that converts a buffer of a shapefile in a GeoJSON object.

Parameters:
Name Type Description
buffer Buffer | ArrayBuffer

Buffer to convert.

Source:
bu/format/shapefile.js
Returns:

A Promise that returns a GeoJSON obejct with the content of the file for the resolve function and an Error for the reject function.

Type
Promise

createVectorSources(name, data)

Returns a Promise that creates an array of source.

Parameters:
Name Type Description
name string

Name for the source.

data Object | string

Input content.

Inherited From:
Source:
bu/format/localfile.js
Returns:

A Promise that returns an array of source created using the input for the resolve function and an Error for the reject function.

Type
Promise

getFeatures(content)

Returns an array of ol.Feature processing the input content. Depending on the current internal format reader, content can be different inputs. For example, for GeoJSON content can be a string with the json or the json object.

Parameters:
Name Type Description
content Object | string

Input content.

Inherited From:
Source:
bu/format/localfile.js
Returns:
Type
Array.<ol.Feature>

getProjectionInfo(content)

Returns a bu.ProjectionInfo from the content. Depending on the current internal format reader, content can be different inputs. For example, for GeoJSON content can be a string with the json or the json object. For other formats overwrite this function.

Parameters:
Name Type Description
content Object | string

Input content.

Inherited From:
Overrides:
Source:
bu/format/localfile.js
Returns:

Projection info with nullable code.

Type
bu.ProjectionInfo

read(input)

Returns a Promise that creates an array of source.

Parameters:
Name Type Description
input File | string | Object | Buffer | ArrayBuffer

Input content. It can be a File, a string, an object, a Buffer or an ArrayBuffer.

Inherited From:
Overrides:
Source:
bu/format/localfile.js
Returns:

A Promise that returns an array of source for the resolve function and an Error for the reject function.

Type
Promise

readFile(file, asText)

Returns a Promise that reads a file and returns its content.

Parameters:
Name Type Description
file File

File to read.

asText boolean

If read file as text or as an array buffer.

Inherited From:
Source:
bu/format/localfile.js
Returns:

A Promise that returns a string with the content of the file for the resolve function and an Error for the reject function.

Type
Promise