Changeset 29376 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationObject.java
- Timestamp:
- 2013-03-19T20:46:10+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationObject.java
r29371 r29376 2 2 3 3 import java.util.Map; 4 import org.openstreetmap.josm.data.osm.*; 4 import org.openstreetmap.josm.data.coor.LatLon; 5 import org.openstreetmap.josm.data.osm.Node; 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 import org.openstreetmap.josm.data.osm.Way; 5 8 6 9 /** … … 9 12 */ 10 13 public class CalibrationObject extends ImageryOffsetBase { 11 private OsmPrimitive object; 12 private long lastUserId; 14 private LatLon[] geometry; 13 15 14 public CalibrationObject(OsmPrimitive object, long lastUserId) { 15 this.object = object; 16 this.lastUserId = lastUserId; 16 public CalibrationObject(LatLon[] geometry) { 17 this.geometry = geometry; 17 18 } 18 19 19 public CalibrationObject(OsmPrimitive object) { 20 this(object, 0); 20 public CalibrationObject( OsmPrimitive p ) { 21 if( p instanceof Node ) 22 geometry = new LatLon[] { ((Node)p).getCoor() }; 23 else if( p instanceof Way ) { 24 geometry = new LatLon[((Way)p).getNodesCount()]; 25 for( int i = 0; i < geometry.length; i++ ) 26 geometry[i] = ((Way)p).getNode(i).getCoor(); 27 } else 28 throw new IllegalArgumentException("Calibration Object can be created either from node or a way"); 21 29 } 22 30 23 public long getLastUserId() {24 return lastUserId;31 public LatLon[] getGeometry() { 32 return geometry; 25 33 } 26 34 27 public OsmPrimitive getObject() {28 return object;29 }30 31 35 @Override 32 36 public void putServerParams( Map<String, String> map ) { 33 37 super.putServerParams(map); 34 map.put("object", object instanceof Node ? "node" : "way"); 35 map.put("id", String.valueOf(object.getId())); 38 StringBuilder sb = new StringBuilder(); 39 for( int i = 0; i < geometry.length; i++ ) { 40 if( i > 0 ) 41 sb.append(','); 42 sb.append(geometry[i].lon()).append(' ').append(geometry[i].lat()); 43 } 44 map.put("geometry", sb.toString()); 36 45 } 37 46 38 47 @Override 39 48 public String toString() { 40 return "CalibrationObject{" + "object=" + object + ", lastUserId=" + lastUserId + "position=" + position + ", date=" + date + ", author=" + author + ", description=" + description + ", abandonDate=" + abandonDate + '}';49 return "CalibrationObject{" + geometry.length + "nodes; position=" + position + ", date=" + date + ", author=" + author + ", description=" + description + ", abandonDate=" + abandonDate + '}'; 41 50 } 42 51 }
Note:
See TracChangeset
for help on using the changeset viewer.