src/write.js
function write(rows, geometry_type, geometries, callback) {

    var TYPE = types.geometries[geometry_type],
        writer = writers[TYPE],
        parts = writer.parts(geometries, TYPE),
        shpLength = 100 + (parts - geometries.length) * 4 + writer.shpLength(geometries),
        shxLength = 100 + writer.shxLength(geometries),
        shpBuffer = new ArrayBuffer(shpLength),
        shpView = new DataView(shpBuffer),
        shxBuffer = new ArrayBuffer(shxLength),
        shxView = new DataView(shxBuffer),
        extent = writer.extent(geometries);

    writeHeader(shpView, TYPE);
    writeHeader(shxView, TYPE);
    writeExtent(extent, shpView);
    writeExtent(extent, shxView);

    writer.write(geometries, extent,
        new DataView(shpBuffer, 100),
        new DataView(shxBuffer, 100),
        TYPE);

    shpView.setInt32(24, shpLength / 2);
    shxView.setInt32(24, (50 + geometries.length * 4));

    var dbfBuf = dbf.structure(rows);

    callback(null, {
        shp: shpView,
        shx: shxView,
        dbf: dbfBuf,
        prj: prj
    });
}
function write(rows, geometry_type, geometries, callback) {

    var TYPE = types.geometries[geometry_type],
        writer = writers[TYPE],
        parts = writer.parts(geometries, TYPE),
        shpLength = 100 + (parts - geometries.length) * 4 + writer.shpLength(geometries),
        shxLength = 100 + writer.shxLength(geometries),
        shpBuffer = new ArrayBuffer(shpLength),
        shpView = new DataView(shpBuffer),
        shxBuffer = new ArrayBuffer(shxLength),
        shxView = new DataView(shxBuffer),
        extent = writer.extent(geometries);

    writeHeader(shpView, TYPE);
    writeHeader(shxView, TYPE);
    writeExtent(extent, shpView);
    writeExtent(extent, shxView);

    writer.write(geometries, extent,
        new DataView(shpBuffer, 100),
        new DataView(shxBuffer, 100),
        TYPE);

    shpView.setInt32(24, shpLength / 2);
    shxView.setInt32(24, (50 + geometries.length * 4));

    var dbfBuf = dbf.structure(rows);

    callback(null, {
        shp: shpView,
        shx: shxView,
        dbf: dbfBuf,
        prj: prj
    });
}
function write ( rows , geometry_type , geometries , callback ) { var TYPE = types . geometries [ geometry_type ] , writer = writers [ TYPE ] , parts = writer . parts ( geometries , TYPE ) , shpLength = 100 + ( parts - geometries . length ) * 4 + writer . shpLength ( geometries ) , shxLength = 100 + writer . shxLength ( geometries ) , shpBuffer = new ArrayBuffer ( shpLength ) , shpView = new DataView ( shpBuffer ) , shxBuffer = new ArrayBuffer ( shxLength ) , shxView = new DataView ( shxBuffer ) , extent = writer . extent ( geometries ) ; writeHeader ( shpView , TYPE ) ; writeHeader ( shxView , TYPE ) ; writeExtent ( extent , shpView ) ; writeExtent ( extent , shxView ) ; writer . write ( geometries , extent , new DataView ( shpBuffer , 100 ) , new DataView ( shxBuffer , 100 ) , TYPE ) ; shpView . setInt32 ( 24 , shpLength / 2 ) ; shxView . setInt32 ( 24 , ( 50 + geometries . length * 4 ) ) ; var dbfBuf = dbf . structure ( rows ) ; callback ( null , { shp : shpView , shx : shxView , dbf : dbfBuf , prj : prj } ) ; }
Low-level writing interface
Low - level writing interface