CataMap¶
svg_to_mesh module¶
This modules allows to read an Inkscape SVG file, parse its elements, and convert them to 3D meshes.
svg_to_mesh module API¶
- class catamap.svg_to_mesh.SvgToMesh(concat_mesh='bygroup')[source]¶
Read SVG, transforms things into meshes
- Parameters:
concat_mesh (str) –
concatenation method between multiple paths in SVG file. ‘merge’: merge all paths in a single mesh ‘time’: use mesh timestep to store each path ‘list’: return a list of meshes ‘bygroup’ (default): return a dict of meshes, one for each main
group, paths are concatenated inside each group
- filter_element(style=None)[source]¶
Assign a processing function / method to the given element, a cleaning function to be called after the associated sub-tree is processed, and a bool to tell if children should be skipped. This method can be overloaded and is called for each XML tree element. The default implementation returns None, which means that there is no specific processing and the default behavior should happen.
- Returns:
proc – proc_callable and clean_callable may be None, meaning that normal processing should happen. The processing callable will be called with 3 arguments: (xml_element, transform_matrix, style_dict). The cleaning callable will be called without arguments. if skip_children is True, children are skipped.
- Return type:
(proc_callable, clean_callable, skip_children) or None
- get_transform(trans, previous=None, no_3d=False)[source]¶
- Parameters:
trans (str or XML element) – if str: transform field in the SVG element. if element: XML element itself
previous (np array or None) – parent transform to be composed with
- read_path(xml_path, trans, style=None)[source]¶
Read a path element as mesh, apply coords transformations
- read_paths(xml_et)[source]¶
Parse XML tree and extract meshes, text and other objects
- Parameters:
xml_et (XML tree) – obtained using xml.etree.cElementTree.parse(svg_filename)
- replace_filter_element(xml)[source]¶
Inside replace_elements, this function is called for each xml element, and should return either the element itself (no replacement), or None (element is discarded), or a replaced XML element.
The default method always returns the input element.
- save_mesh_dict(meshes, dirname, mesh_format='.obj', mesh_wf_format='.obj', lights=None)[source]¶
mesh_format may be a valid mesh extension (“.obj”, “.gii”, “.mesh”) or GLTF (“.gltf” or “.glb”), or None (not saved here).
If GLTF is used a scene dict (JSON) is returned in the output summary under the key “gltf_scene”.
- transform_style(xml_path, trans)[source]¶
adapt style in path/rect to scale changes (stroke width etc)
diff_svg module¶
Print differences between two SVG maps.
Uses the yaml module (pip install pyyaml
).
The output is a hierarchical dictionary of differences between the two maps. Differences in tags (properties) and children are recorded. Item keys are their “id” property, which should be unique in the files, and are displayed hierarchically.
Used as a program, the output is in YAML format (mostly human readable)
To use it, try:
python -m catamap.diff_svg --h
It will print the command doc and parameters.
diff_svg module API¶
- catamap.diff_svg.diff_element(el1, el2, verbose_depth=0, verbose_depth_max=1)[source]¶
Compare two SVG XML trees, record differences in both properties and children in a readable dictionary.
BDAlti maps module¶
Convertion tools for BDAlti maps (https://geoservices.ign.fr/documentation/diffusion/telechargement-donnees-libres.html#bd-alti) and their use in catamap
.
API¶
- catamap.altitude.bdalti.build_meta_table(ima_fnames)[source]¶
build the metadata table from converted .ima files
ima_fnames: pattern with a “%s”, same as out_fnames in convert_raw_maps()
- catamap.altitude.bdalti.convert_raw_map(fname, out_fname)[source]¶
convert one raw map from bdalti (.asc) to .ima format
- catamap.altitude.bdalti.convert_raw_maps(fnames, out_fnames)[source]¶
convert all raw data files from bdalti (.asc) to .ima format
- fnames:
input files pattern (used with glob.glob())
- out_fnames:
output files pattern, should contain a “%s” pattern