geeViz.eeAuth.vector_convert¶
Convert an uploaded vector file to a GeoJSON FeatureCollection in EPSG:4326.
Backs POST <proxy base>/convert/vector on both servers that serve
the geeViz viewer: the eeAuth proxy app (geeViz.eeAuth.server,
mounted at /ee-api) and geeViz’s own local static server
(geeView._GeeVizRequestHandler, for direct-token mode). Both call
handle_upload(), so the two behave the same.
Reads with GDAL in-process through pyogrio (its wheels bundle GDAL with
the LIBKML driver); nothing is shelled out and no third-party service is
contacted. Supported: a zipped shapefile (.zip), KML, KMZ, GeoJSON
(.geojson/.json), GeoPackage, GPX and FlatGeobuf. Every layer is
read and merged; each feature gets a layer property naming its layer
(a source field already called layer is kept as layer_original),
and the response says when layers were combined.
Uploads are untrusted, so:
the upload, the unpacked size and the zip member count are capped (see the limits below);
zips and KMZs are unpacked by this module, never by GDAL, into a fresh temp dir, refusing members that would land outside it (zip slip), symbolic links and encrypted members, and counting the bytes actually written; only vector files and shapefile sidecars are unpacked;
text files carrying GDAL’s VRT or streamed-algorithm markers are refused before GDAL opens them (both can read other local files), and each layer’s driver must be one expected for its extension;
raster files are refused;
more features or vertices than the caps is an error, never a silent truncation;
conversion runs in a worker thread with a timeout and at most
MAX_CONCURRENTat once, and the temp dir is always removed.
The endpoints add no CORS headers (same as the proxy’s other routes) and
refuse browser requests marked Sec-Fetch-Site: cross-site.
Functions
|
Convert one uploaded file. |
|
Convert a request: |
|
True for |
|
|
|
|
|
|
Exceptions
|
A conversion that cannot be done; |
- exception geeViz.eeAuth.vector_convert.ConvertError(error, hint='', status=400)[source]¶
Bases:
ExceptionA conversion that cannot be done;
errorandhintgo to the user.
- geeViz.eeAuth.vector_convert.is_convert_path(path, prefix='/ee-api')[source]¶
True for
<prefix>/convert/vectorand<prefix>/t/<tenant>/convert/vector.
- geeViz.eeAuth.vector_convert.convert_bytes(filename, data)[source]¶
Convert one uploaded file. Returns a GeoJSON FeatureCollection dict.
Foreign members:
layers([{name, features}]) andnotes(plain-language sentences: layers combined, reprojection, a missing projection read as longitude/latitude). RaisesConvertError.
- geeViz.eeAuth.vector_convert.parse_multipart(content_type, body)[source]¶
(filename, bytes)of the one file in a multipart/form-data body.
- geeViz.eeAuth.vector_convert.request_rejection(headers)[source]¶
(status, body)to send without reading the body, orNone.Refuses cross-site browser posts and declared oversize bodies.
- geeViz.eeAuth.vector_convert.oversize_reply()[source]¶
(413, body)for a body found to be overmax_body_bytes()while reading.
- geeViz.eeAuth.vector_convert.handle_upload(headers, body)[source]¶
Convert a request:
(status, JSON bytes). Never raises.headersis any mapping of request headers;bodythe raw request body, read by the caller up tomax_body_bytes()plus one.