gnome.utilities.file_tools.haz_files

A module that did contain various functions for reading and writing assorted HAZMAT file formats.

Now it’s just BNA format

Other stuff is now maintained in either the ood_utils package and/or libgoods

Functions

GetNextBNAPolygon(f[, dtype])

Utility function that returns the next polygon from a BNA file

ReadBNA(filename[, polytype, dtype])

Read a bna file.

Module Contents

gnome.utilities.file_tools.haz_files.GetNextBNAPolygon(f, dtype=np.float64)

Utility function that returns the next polygon from a BNA file

returns: (points, poly_type, name, sname) where:

points: Nx2numpy array of floats with the points poly_type: one of “point”, “line”, “poly” name: name defined in the BNA sname: secondary name defined in the BNA

NOTE: It is the BNA standard to duplicate the first and last points.

In that case, the duplicated last point is removed.

“holes” in polygons are not supported in this code.

See:

http://www.softwright.com/faq/support/boundary_file_bna_format.html

NOTE: This code doesn’t allow extra spaces around the commas in the

header line. If there are no commas allowed in the name, it would be easier to simply split on the commas (or march through the line looking for the quotes – regex?)

gnome.utilities.file_tools.haz_files.ReadBNA(filename, polytype='list', dtype=np.float64)

Read a bna file.

Parameters:
  • filename – A filename to write to.

  • polytype (one of: ("list", "PolygonSet", "BNADataClass")) – The type of polygon structure to return.

Returns:

returns the BNA data contents

Return type:

Results are returned as one of:

list:

A list of tuples (points, poly_type, name, secondary name)

PolygonSet:

A geometry.polygons.PolygonSet object, with metadata (poly_type, name, secondary name)

BNADataClass:

A BNAData class object. This may be broken now!

The dtype parameter specifies what numpy data type you want the points data in – it defaults to float (C double)