5
Copyright 2014-2016 Andreas Würl
7
Licensed under the Apache License, Version 2.0 (the "License");
8
you may not use this file except in compliance with the License.
9
You may obtain a copy of the License at
11
http://www.apache.org/licenses/LICENSE-2.0
13
Unless required by applicable law or agreed to in writing, software
14
distributed under the License is distributed on an "AS IS" BASIS,
15
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
See the License for the specific language governing permissions and
17
limitations under the License.
21
from geographiclib.geodesic import Geodesic
22
from geographiclib.polygonarea import PolygonArea
27
class StrikeCluster(object):
29
class for building strike cluster objects
35
self.interval_seconds = 0
39
def with_id(self, cluster_id):
40
self.cluster_id = cluster_id
43
def with_timestamp(self, timestamp):
44
self.timestamp = timestamp
47
def with_interval_seconds(self, interval_seconds):
48
self.interval_seconds = interval_seconds
51
def with_shape(self, shape):
56
def with_strike_count(self, strike_count):
57
self.strike_count = strike_count
61
if self.shape is not None:
62
poly_area = PolygonArea(Geodesic.WGS84)
65
for (x, y) in zip(self.shape.coords.xy[0], self.shape.coords.xy[1]):
66
poly_area.AddPoint(x, y)
67
area = round(poly_area.Compute(False, True)[2] / 1e6, 1)
75
return data.StrikeCluster(self.cluster_id, self.timestamp, self.interval_seconds, self.shape, self.strike_count,