Changeset 7575 in josm for trunk/src/org/openstreetmap/josm/data/DataSource.java
- Timestamp:
- 2014-09-21T23:00:38+02:00 (10 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/DataSource.java
r7573 r7575 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.data .osm;2 package org.openstreetmap.josm.data; 3 3 4 import org.openstreetmap.josm.data.Bounds; 4 import java.awt.geom.Area; 5 import java.util.ArrayList; 6 import java.util.Collection; 7 import java.util.List; 8 5 9 import org.openstreetmap.josm.tools.CheckParameterUtil; 6 10 7 11 /** 8 12 * A data source, defined by bounds and textual description for the origin. 9 * @since 247 13 * @since 247 (creation) 14 * @since 7575 (moved package) 10 15 */ 11 16 public class DataSource { 17 12 18 /** 13 19 * The bounds of this data source 14 20 */ 15 21 public final Bounds bounds; 22 16 23 /** 17 24 * The textual description of the origin (example: "OpenStreetMap Server") … … 30 37 this.origin = origin; 31 38 } 39 40 @Override 41 public int hashCode() { 42 final int prime = 31; 43 int result = 1; 44 result = prime * result + ((bounds == null) ? 0 : bounds.hashCode()); 45 result = prime * result + ((origin == null) ? 0 : origin.hashCode()); 46 return result; 47 } 48 49 @Override 50 public boolean equals(Object obj) { 51 if (this == obj) 52 return true; 53 if (obj == null) 54 return false; 55 if (getClass() != obj.getClass()) 56 return false; 57 DataSource other = (DataSource) obj; 58 if (bounds == null) { 59 if (other.bounds != null) 60 return false; 61 } else if (!bounds.equals(other.bounds)) 62 return false; 63 if (origin == null) { 64 if (other.origin != null) 65 return false; 66 } else if (!origin.equals(other.origin)) 67 return false; 68 return true; 69 } 70 71 @Override 72 public String toString() { 73 return "DataSource [bounds=" + bounds + ", origin=" + origin + "]"; 74 } 75 76 /** 77 * Returns the total area of downloaded data (the "yellow rectangles"). 78 * @param dataSources list of data sources 79 * @return Area object encompassing downloaded data. 80 * @see Data#getDataSourceArea() 81 */ 82 public static Area getDataSourceArea(Collection<DataSource> dataSources) { 83 if (dataSources == null || dataSources.isEmpty()) { 84 return null; 85 } 86 Area a = new Area(); 87 for (DataSource source : dataSources) { 88 // create area from data bounds 89 a.add(new Area(source.bounds.asRect())); 90 } 91 return a; 92 } 93 94 /** 95 * <p>Replies the list of data source bounds.</p> 96 * 97 * <p>Dataset maintains a list of data sources which have been merged into the 98 * data set. Each of these sources can optionally declare a bounding box of the 99 * data it supplied to the dataset.</p> 100 * 101 * <p>This method replies the list of defined (non {@code null}) bounding boxes.</p> 102 * @param dataSources list of data sources 103 * 104 * @return the list of data source bounds. An empty list, if no non-null data source 105 * bounds are defined. 106 * @see Data#getDataSourceBounds() 107 */ 108 public static List<Bounds> getDataSourceBounds(Collection<DataSource> dataSources) { 109 if (dataSources == null) { 110 return null; 111 } 112 List<Bounds> ret = new ArrayList<>(dataSources.size()); 113 for (DataSource ds : dataSources) { 114 if (ds.bounds != null) { 115 ret.add(ds.bounds); 116 } 117 } 118 return ret; 119 } 32 120 }
Note:
See TracChangeset
for help on using the changeset viewer.