source: josm/trunk/src/org/openstreetmap/josm/io/imagery/WMSRequest.java@ 4745

Last change on this file since 4745 was 4745, checked in by jttt, 12 years ago

Add precache wms tiles action to gpx layers (it will download wms tiles along track to cache for faster work afterwards)

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.imagery;
3
4import java.awt.image.BufferedImage;
5
6import org.openstreetmap.josm.data.imagery.GeorefImage.State;
7import org.openstreetmap.josm.gui.layer.WMSLayer.PrecacheTask;
8
9public 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 final PrecacheTask precacheTask; // Download even when wms tile is not currently visible (precache)
15 private final boolean allowPartialCacheMatch;
16 private int priority;
17 private boolean hasExactMatch;
18 // Result
19 private State state;
20 private BufferedImage image;
21
22 public WMSRequest(int xIndex, int yIndex, double pixelPerDegree, boolean real, boolean allowPartialCacheMatch) {
23 this(xIndex, yIndex, pixelPerDegree, real, allowPartialCacheMatch, null);
24 }
25
26 public WMSRequest(int xIndex, int yIndex, double pixelPerDegree, boolean real, boolean allowPartialCacheMatch, PrecacheTask precacheTask) {
27 this.xIndex = xIndex;
28 this.yIndex = yIndex;
29 this.pixelPerDegree = pixelPerDegree;
30 this.real = real;
31 this.precacheTask = precacheTask;
32 this.allowPartialCacheMatch = allowPartialCacheMatch;
33 }
34
35
36 public void finish(State state, BufferedImage image) {
37 this.state = state;
38 this.image = image;
39 }
40
41 public int getXIndex() {
42 return xIndex;
43 }
44
45 public int getYIndex() {
46 return yIndex;
47 }
48
49 public double getPixelPerDegree() {
50 return pixelPerDegree;
51 }
52
53 @Override
54 public int hashCode() {
55 final int prime = 31;
56 int result = 1;
57 long temp;
58 temp = Double.doubleToLongBits(pixelPerDegree);
59 result = prime * result + (int) (temp ^ (temp >>> 32));
60 result = prime * result + xIndex;
61 result = prime * result + yIndex;
62 return result;
63 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (this == obj)
68 return true;
69 if (obj == null)
70 return false;
71 if (getClass() != obj.getClass())
72 return false;
73 WMSRequest other = (WMSRequest) obj;
74 if (Double.doubleToLongBits(pixelPerDegree) != Double
75 .doubleToLongBits(other.pixelPerDegree))
76 return false;
77 if (xIndex != other.xIndex)
78 return false;
79 if (yIndex != other.yIndex)
80 return false;
81 if (allowPartialCacheMatch != other.allowPartialCacheMatch)
82 return false;
83 return true;
84 }
85
86 public void setPriority(int priority) {
87 this.priority = priority;
88 }
89
90 public int getPriority() {
91 return priority;
92 }
93
94 @Override
95 public int compareTo(WMSRequest o) {
96 return priority - o.priority;
97 }
98
99 public State getState() {
100 return state;
101 }
102
103 public BufferedImage getImage() {
104 return image;
105 }
106
107 @Override
108 public String toString() {
109 return "WMSRequest [xIndex=" + xIndex + ", yIndex=" + yIndex
110 + ", pixelPerDegree=" + pixelPerDegree + "]";
111 }
112
113 public boolean isReal() {
114 return real;
115 }
116
117 public boolean isPrecacheOnly() {
118 return precacheTask != null;
119 }
120
121 public PrecacheTask getPrecacheTask() {
122 return precacheTask;
123 }
124
125 public boolean isAllowPartialCacheMatch() {
126 return allowPartialCacheMatch;
127 }
128
129 public boolean hasExactMatch() {
130 return hasExactMatch;
131 }
132
133 public void setHasExactMatch(boolean hasExactMatch) {
134 this.hasExactMatch = hasExactMatch;
135 }
136}
Note: See TracBrowser for help on using the repository browser.