1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.imagery;
|
---|
3 |
|
---|
4 | import java.awt.image.BufferedImage;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.imagery.GeorefImage;
|
---|
7 | import org.openstreetmap.josm.data.imagery.GeorefImage.State;
|
---|
8 |
|
---|
9 | public class WMSRequest implements Comparable<WMSRequest> {
|
---|
10 | private final int xIndex;
|
---|
11 | private final int yIndex;
|
---|
12 | private final double pixelPerDegree;
|
---|
13 | private final boolean real; // Download even if autodownloading is disabled
|
---|
14 | private int priority;
|
---|
15 | // Result
|
---|
16 | private State state;
|
---|
17 | private BufferedImage image;
|
---|
18 |
|
---|
19 | public WMSRequest(int xIndex, int yIndex, double pixelPerDegree, boolean real) {
|
---|
20 | this.xIndex = xIndex;
|
---|
21 | this.yIndex = yIndex;
|
---|
22 | this.pixelPerDegree = pixelPerDegree;
|
---|
23 | this.real = real;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public void finish(State state, BufferedImage image) {
|
---|
27 | this.state = state;
|
---|
28 | this.image = image;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public int getXIndex() {
|
---|
32 | return xIndex;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public int getYIndex() {
|
---|
36 | return yIndex;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public double getPixelPerDegree() {
|
---|
40 | return pixelPerDegree;
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public int hashCode() {
|
---|
45 | final int prime = 31;
|
---|
46 | int result = 1;
|
---|
47 | long temp;
|
---|
48 | temp = Double.doubleToLongBits(pixelPerDegree);
|
---|
49 | result = prime * result + (int) (temp ^ (temp >>> 32));
|
---|
50 | result = prime * result + xIndex;
|
---|
51 | result = prime * result + yIndex;
|
---|
52 | return result;
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | public boolean equals(Object obj) {
|
---|
57 | if (this == obj)
|
---|
58 | return true;
|
---|
59 | if (obj == null)
|
---|
60 | return false;
|
---|
61 | if (getClass() != obj.getClass())
|
---|
62 | return false;
|
---|
63 | WMSRequest other = (WMSRequest) obj;
|
---|
64 | if (Double.doubleToLongBits(pixelPerDegree) != Double
|
---|
65 | .doubleToLongBits(other.pixelPerDegree))
|
---|
66 | return false;
|
---|
67 | if (xIndex != other.xIndex)
|
---|
68 | return false;
|
---|
69 | if (yIndex != other.yIndex)
|
---|
70 | return false;
|
---|
71 | return true;
|
---|
72 | }
|
---|
73 |
|
---|
74 | public void setPriority(int priority) {
|
---|
75 | this.priority = priority;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public int getPriority() {
|
---|
79 | return priority;
|
---|
80 | }
|
---|
81 |
|
---|
82 | @Override
|
---|
83 | public int compareTo(WMSRequest o) {
|
---|
84 | return priority - o.priority;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public State getState() {
|
---|
88 | return state;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public BufferedImage getImage() {
|
---|
92 | return image;
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Override
|
---|
96 | public String toString() {
|
---|
97 | return "WMSRequest [xIndex=" + xIndex + ", yIndex=" + yIndex
|
---|
98 | + ", pixelPerDegree=" + pixelPerDegree + "]";
|
---|
99 | }
|
---|
100 |
|
---|
101 | public boolean isReal() {
|
---|
102 | return real;
|
---|
103 | }
|
---|
104 | }
|
---|