MCPcopy Create free account
hub / github.com/OSGeo/PROJ / main

Function main

docs/plot/plot.py:313–354  ·  view source on GitHub ↗

Run main function of plotting script. Parses json-file with plot setups and runs the plotting for each plot setup.

(plotdefs, outdir, plots=[])

Source from the content-addressed store, hash-verified

311
312
313def main(plotdefs, outdir, plots=[]):
314 """Run main function of plotting script.
315
316 Parses json-file with plot setups and runs the plotting
317 for each plot setup.
318 """
319 try:
320 # Check 'proj' command, show version
321 proc = run_proj_cmd(text=True)
322 print(proc.stderr.splitlines()[0])
323 except (FileNotFoundError, OSError) as e:
324 sys.stderr.write(
325 "'proj' binary not found, set the PROJ_EXE environment variable "
326 "to point to your local 'proj' binary\n{}\n".format(e)
327 )
328 return 1
329
330 outdir = Path(outdir)
331 if not outdir.exists():
332 outdir.mkdir(parents=True)
333 if not outdir.is_dir():
334 raise OSError("outdir is not a directory")
335
336 plotdefs = json.loads(Path(plotdefs).read_text())
337
338 data = {
339 ("line", "low"): geojson2geom_array(LINE_LOW),
340 ("line", "med"): geojson2geom_array(LINE_MED),
341 ("poly", "low"): geojson2geom_array(POLY_LOW),
342 ("poly", "med"): geojson2geom_array(POLY_MED),
343 }
344
345 for i, plotdef in enumerate(plotdefs):
346 if plots != [] and plotdef["name"] not in plots:
347 continue
348
349 print("{}: {!r} {}".format(i, plotdef["filename"], plotdef["projstring"]))
350 if "skip" in plotdef.keys():
351 print("skipping")
352 continue
353
354 plotproj(plotdef, data[(plotdef["type"], plotdef["res"])], outdir)
355
356
357if __name__ == "__main__":

Callers 1

plot.pyFile · 0.70

Calls 7

run_proj_cmdFunction · 0.85
printFunction · 0.85
geojson2geom_arrayFunction · 0.85
plotprojFunction · 0.85
existsMethod · 0.80
mkdirMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected