Changeset 2402 for inundation/pmesh/mesh_interface.py
- Timestamp:
- Feb 14, 2006, 3:29:10 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pmesh/mesh_interface.py
r2401 r2402 4 4 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 5 5 6 from coordinate_transforms.geo_reference import Geo_reference 6 from coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE 7 7 from utilities.polygon import populate_polygon 8 from utilities.numerical_tools import ensure_numeric 9 from Numeric import Float 8 10 9 11 # This is due to pmesh being a package and a module and … … 13 15 except ImportError: 14 16 from mesh import Mesh 15 17 18 16 19 def create_mesh_from_regions(bounding_polygon, 17 20 boundary_tags, … … 24 27 """Create mesh from bounding polygons, and resolutions. 25 28 26 Polygon is a list of points in Eastings and Northings, absolute 29 bounding_polygon is a list of points in Eastings and Northings, 30 relative to the poly_geo_reference. 27 31 28 32 Boundary tags is a dictionary of symbolic tags. For every tag there … … 39 43 40 44 poly_geo_reference is the geo_reference of the polygons. 41 If none, assume absolute. 45 If none, assume absolute. Please pass one though, since absolute 46 references have a zone. 42 47 43 48 mesh_geo_reference is the geo_reference of the mesh to be created. 44 If none, assume absolute. 49 If none is given one will be automatically generated. It was use 50 the lower left hand corner of bounding_polygon (absolute) 51 as the x and y values for the geo_ref. 45 52 46 53 Returns the mesh instance if no finename is given 47 54 48 55 """ 56 #FIXME (OLE-DSG) 49 57 # To do make maximum_triangle_area optional? 50 58 # check the segment indexes - throw an error if they are out of bounds 51 52 #IDEA (Ole): Let us work out what the mesh_geo_reference is automatically:53 #If bounding_polygon is absolute it would look as follows:54 #55 #from utilities.numerical_tools import ensure_numeric56 #bounding_polygon = ensure_numeric(bounding_polygon) #Make it Numeric57 #xllcorner = min(bounding_polygon[:,0])58 #yllcorner = min(bounding_polygon[:,1])59 #60 #mesh_geo_reference = Geo_reference(xllcorner = xllcorner,61 # yllcorner = yllcorner,62 # zone = "zone from bounding polygon")63 59 # 64 60 #In addition I reckon the polygons could be of class Geospatial_data 61 62 if mesh_geo_reference is None: 63 bounding_polygon = ensure_numeric(bounding_polygon, Float) 64 xllcorner = min(bounding_polygon[:,0]) 65 yllcorner = min(bounding_polygon[:,1]) 66 # 67 if poly_geo_reference is None: 68 zone = DEFAULT_ZONE 69 else: 70 zone = poly_geo_reference.get_zone() 71 [(xllcorner,yllcorner)] = poly_geo_reference.get_absolute( \ 72 [(xllcorner,yllcorner)]) 73 # create a geo_ref, based on the llc of the bounding_polygon 74 mesh_geo_reference = Geo_reference(xllcorner = xllcorner, 75 yllcorner = yllcorner, 76 zone = zone) 65 77 66 78 m = Mesh(geo_reference=mesh_geo_reference) … … 118 130 else: 119 131 m.export_mesh_file(filename) 132 133
Note: See TracChangeset
for help on using the changeset viewer.