open_location_code/
codearea.rs1use geo::{Point};
2
3pub struct CodeArea {
4 pub south: f64,
5 pub west: f64,
6 pub north: f64,
7 pub east: f64,
8 pub center: Point<f64>,
9 pub code_length: usize,
10}
11
12impl CodeArea {
13 pub fn new(south: f64, west: f64, north: f64, east: f64, code_length: usize) -> CodeArea {
14 CodeArea {
15 south: south, west: west, north: north, east: east,
16 center: Point::new((west + east) / 2f64, (south + north) / 2f64),
17 code_length: code_length
18 }
19 }
20
21 pub fn merge(self, other: CodeArea) -> CodeArea {
22 CodeArea::new(
23 self.south + other.south,
24 self.west + other.west,
25 self.north + other.north,
26 self.east + other.east,
27 self.code_length + other.code_length
28 )
29 }
30}
31