Open brandonreavis opened 9 years ago
Yeah, this would be really nice for manipulation of geojson / other simple formats. Writing to a temp file for GDAL to handle it isn't ideal.
FYI : you can pass the VRT spec as a string directly into gdal.open()
:
let vrt = `<OGRVRTDataSource>
<OGRVRTLayer name="${filenameWithoutExtension}">
<SrcDataSource>${file.fullPath}</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:27700</LayerSRS>
<GeometryField encoding="PointFromColumns" x="${xCoordName}" y="${yCoordName}"/>
</OGRVRTLayer>
</OGRVRTDataSource>`;
const source_dataset = gdal.open(buildVRT(file));
console.log(source_dataset.layers);
if (source_dataset.layers.count() > 1)
throw new Error(`there are ${source_dataset.layers.count()} layers in the file`);
const layer = source_dataset.layers.get(0);
return layer.features; // cursor
This might be taking things a bit too far, but there are cases where being able to do something like this would be nice:
This is can be done with the VSI mem handler as shown here.
It would require keeping track of which buffer is opened with which dataset, so that the file buffer never gets freed until the dataset is closed.