Skip to content

Commit

Permalink
Horizontal changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Serrano committed Dec 4, 2017
1 parent b8522d3 commit b8d091f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions geomodelr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,41 @@ def __init__( self, geolojson, delete=True ):
# Calculate direction and base point.
try:
if base_section['transform']['type'] == 'plane':
base_line = base_section['transform']['line']
transform = 'plane'
elif base_section['transform']['type'] == 'horizontal':
base_line = None
transform = 'horizontal'
if not 'orientation' in base_section['transform'] or base_section['transform']['orientation'] == 'vertical':
base_line = base_section['transform']['line']
orientation = 'vertical'
elif base_section['transform']['orientation'] == 'horizontal':
base_line = None
orientation = 'horizontal'
else:
raise shared.ModelException("The base section should be a plane")
else:
raise shared.ModelException("The base section should be horizontal or plane")
raise shared.ModelException("The base section should be a plane")
except TypeError:
raise shared.ModelException("The model needs minimum a base cross section.")

if transform == 'plane':
if orientation == 'vertical':
base_point = np.array(base_line[0][:2])
direction = np.array(base_line[1][:2])-base_point
direction = direction/la.norm(direction)
horizontal = False
else:
base_point = None
direction = None
horizontal = True

for idx, feature in enumerate(self.geojson['features']):
if feature['geology_type'] == 'section' and 'interpolation' in feature['properties'] and feature['properties']['interpolation']:
if transform == 'plane':
if orientation == 'vertical':
cut, cs = shared.cross_idx_repr( feature, base_line )
sect = [feature['name'], cut, cs['points'], cs['polygons'], cs['units'], cs['lines'], cs['lnames']]
sections.append(sect)
else:
cs = shared.points_index_repr(feature)
sect = [feature['name'], feature['transform']['height'], cs['points'], cs['polygons'], cs['units'], cs['lines'], cs['lnames']]

sections.append(sect)

# Obtain the possible farthest cuts to add triangles towards them.
bbox = self.geojson['bbox']
if horizontal:
if orientation == 'horizontal':
super(GeologicalModel, self).__init__(bbox, geomap, topography, sections)
else:
super(GeologicalModel, self).__init__(bbox, list(base_point), list(direction), geomap, topography, sections)
Expand Down

0 comments on commit b8d091f

Please sign in to comment.