Skip to content

Commit

Permalink
Pep and Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
uniomni committed Aug 31, 2012
1 parent 6b41cbc commit 1dbf6ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Expand Up @@ -6,8 +6,6 @@
from safe.common.utilities import ugettext as _
from safe.common.tables import Table, TableRow

from safe.storage.interpolation import interpolate_polygon_raster


class FloodEvacuationFunctionVectorHazard(FunctionProvider):
"""Risk plugin for flood evacuation
Expand Down
17 changes: 10 additions & 7 deletions safe/storage/interpolation.py
Expand Up @@ -20,12 +20,11 @@
from utilities import DEFAULT_ATTRIBUTE



# FIXME (Ole): Not finished (issue #101)

# FIXME: Add mode parameter too
def assign_hazard_values_to_exposure_data(hazard, exposure,
layer_name=None, attribute_name=None):
layer_name=None,
attribute_name=None):
"""Assign hazard values to exposure data
This is the high level wrapper around interpolation functions for different
Expand All @@ -35,7 +34,8 @@ def assign_hazard_values_to_exposure_data(hazard, exposure,
hazard: Layer representing the hazard levels
exposure: Layer representing the exposure data
layer_name: Optional name of returned layer.
If None (default) the name of the exposure layer is used for the returned layer.
If None (default) the name of the exposure layer is used for
the returned layer.
attribute_name: Name for new attribute if one needs to be created.
If None (default) the name of hazard is used
Expand Down Expand Up @@ -67,11 +67,14 @@ def assign_hazard_values_to_exposure_data(hazard, exposure,
with the following methodologies used:
Polygon-Point: Clip points to polygon and assign polygon attributes to them.
Polygon-Point: Clip points to polygon and assign polygon attributes
to them.
Polygon-Line: * Not Implemented *
Polygon-Polygon: * Not Implemented *
Polygon-Raster: Convert raster to points, clip to polygon, assign values and return point data
Raster-Point: Bilinear (or constant) interpolation as currently implemented
Polygon-Raster: Convert raster to points, clip to polygon, assign values
and return point data
Raster-Point: Bilinear (or constant) interpolation as currently
implemented
Raster-Line: * Not Implemented *
Raster-Polygon: Calculate centroids and use Raster - Point algorithm
Raster-Raster: Exposure raster is returned as is
Expand Down
8 changes: 6 additions & 2 deletions safe/storage/vector.py
Expand Up @@ -23,6 +23,7 @@
from safe.common.dynamic_translations import names as internationalised_titles
from safe.common.exceptions import ReadLayerError, WriteLayerError
from safe.common.exceptions import GetDataError, InaSAFEError
from safe.common.utilities import ugettext as _

from layer import Layer
from projection import Projection
Expand Down Expand Up @@ -293,7 +294,7 @@ def read_from_file(self, filename):
* http://www.packtpub.com/article/geospatial-data-python-geometry
"""

basename, _ = os.path.splitext(filename)
basename = os.path.splitext(filename)[0]

# Look for any keywords
self.keywords = read_keywords(basename + '.keywords')
Expand Down Expand Up @@ -770,7 +771,7 @@ def get_topN(self, attribute, N=10):
A.sort()

# Pick top N and unpack
_, data, geometry = zip(*A[-N:])
data, geometry = zip(*A[-N:])[1:]

# Create new Vector instance and return
return Vector(data=data,
Expand Down Expand Up @@ -868,7 +869,10 @@ def convert_line_to_points(V, delta):
for i in range(N):
c = points_along_line(geometry[i], delta)
# We need to create a data entry for each point.
# FIXME (Ole): What on earth is this?
# pylint: disable=W0621
new_data.extend([data[i] for _ in c])
# pylint: enable=W0621
points.extend(c)

# Create new point vector layer with same attributes and return
Expand Down

0 comments on commit 1dbf6ec

Please sign in to comment.