-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fea7dca
commit 5f23ef3
Showing
5 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import gdal from "gdal-async"; | ||
import { Logger } from "../logger"; | ||
|
||
export async function getLayerIdentifiers(path: string, logger: Logger) { | ||
const ids: string[] = []; | ||
const data = await logger.exec( | ||
["gdalinfo", ["-json", path]], | ||
"Problem getting layer identifiers" | ||
); | ||
const info = JSON.parse(data); | ||
const metadata = info.metadata || {}; | ||
const subdatasets = metadata["SUBDATASETS"] || {}; | ||
for (const key in subdatasets) { | ||
if (/_NAME$/.test(key)) { | ||
ids.push(subdatasets[key]); | ||
} | ||
} | ||
console.log("ids", ids); | ||
return ids; | ||
} | ||
|
||
export async function convertToGeoTiff( | ||
layerId: string, | ||
outputPath: string, | ||
logger: Logger | ||
) { | ||
await logger.exec( | ||
["gdal_translate", ["-co", "COMPRESS=DEFLATE", layerId, outputPath]], | ||
"Problem converting to GeoTIFF" | ||
); | ||
return outputPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters