Skip to content

Instantly share code, notes, and snippets.

@eyeNsky
eyeNsky / P1gpu.cpp
Last active June 15, 2026 19:57
GPU for P1
// Try g4dn.metal
// Try to enable GPU if available, otherwise fall back to CPU.
std::string gpuMsg;
if (P1::ImageSdk::IsCudaSupported(gpuMsg)) {
int ndev = P1::ImageSdk::GetNumberOfCudaDevices();
std::cout << "CUDA available, devices: " << ndev << ". Using device 0.\n";
if (ndev > 0) {
P1::ImageSdk::SetCudaDevice(0);
P1::ImageSdk::SetArchitecture(P1::ImageSdk::Architecture::Cuda);
}
@eyeNsky
eyeNsky / mapnik-rotate
Last active November 27, 2018 21:55
rotate mapnik output map
Mapnik supports the PROJ.4 WKT for projections and buried deep in the doc's is one called
'Two Point Equidistant'. You provide the left and right points and the map is rotated
such that these two points are horizontal in the output.
This allows you to rotate the map to any angle (including south up!!) and the text is
rendered correctly! You don't have to change the projections of your input vectors.
Simply tweak the mapnik generate_image.py script like this:
Change: