1 | // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
|
---|
2 | package cadastre_fr;
|
---|
3 |
|
---|
4 | import java.io.Serializable;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.Main;
|
---|
7 | import org.openstreetmap.josm.data.Bounds;
|
---|
8 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
9 |
|
---|
10 | public class EastNorthBound implements Serializable {
|
---|
11 |
|
---|
12 | private static final long serialVersionUID = 8451650309216472069L;
|
---|
13 |
|
---|
14 | public EastNorth min, max;
|
---|
15 | public EastNorthBound(EastNorth min, EastNorth max) {
|
---|
16 | this.min = min;
|
---|
17 | this.max = max;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public boolean contains(EastNorth eastNorth) {
|
---|
21 | if (eastNorth.east() < min.east() || eastNorth.north() < min.north())
|
---|
22 | return false;
|
---|
23 | if (eastNorth.east() > max.east() || eastNorth.north() > max.north())
|
---|
24 | return false;
|
---|
25 | return true;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public EastNorthBound interpolate(EastNorthBound en2, double proportion) {
|
---|
29 | EastNorthBound enb = new EastNorthBound(this.min.interpolate(en2.min, proportion),
|
---|
30 | this.max.interpolate(en2.max, proportion));
|
---|
31 | return enb;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public Bounds toBounds() {
|
---|
35 | return new Bounds(Main.proj.eastNorth2latlon(min), Main.proj.eastNorth2latlon(max));
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override public String toString() {
|
---|
39 | return "EastNorthBound[" + min.east() + "," + min.north() + "," + max.east() + "," + max.north() + "]";
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|